Skip to content

@use parameter gets ignored in value classes #23302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Linyxus opened this issue Jun 2, 2025 · 1 comment · May be fixed by #23324
Open

@use parameter gets ignored in value classes #23302

Linyxus opened this issue Jun 2, 2025 · 1 comment · May be fixed by #23324
Assignees
Labels
area:experimental:cc Capture checking related itype:bug

Comments

@Linyxus
Copy link
Contributor

Linyxus commented Jun 2, 2025

Compiler version

main

Minimized code

import language.experimental.captureChecking
import caps.*

final class Runner(val dummy: Int) extends AnyVal {
  def runOps(@use ops: List[() => Unit]): Unit = ops.foreach(op => op())  // error
}

final class Runner1 {
  def runOps(@use ops: List[() => Unit]): Unit = ops.foreach(op => op())  // ok
}

Output

-- Error: issues/cc-reach-ext.scala:5:61 ---------------------------------------
5 |  def runOps(@use ops: List[() => Unit]): Unit = ops.foreach(op => op())  // error
  |                                                             ^^^^^^^^^^
  |Local reach capability ops* leaks into capture scope of method runOps$extension.
  |To allow this, the parameter ops should be declared with a @use annotation

Expectation

Both runOps methods should compile. Note that the only differences between them are whether they are a value class (whether it extends AnyVal).

@Linyxus Linyxus added itype:bug area:experimental:cc Capture checking related labels Jun 2, 2025
@Linyxus
Copy link
Contributor Author

Linyxus commented Jun 2, 2025

This is a minimisation of the failing stdlib method in #23291. It is related to value classes and extension methods, it seems that the @use annotation gets discarded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:experimental:cc Capture checking related itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants