Skip to content
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

Type argument of asInstanceOf is boxed #20224

Closed
Linyxus opened this issue Apr 18, 2024 · 1 comment · Fixed by #20221
Closed

Type argument of asInstanceOf is boxed #20224

Linyxus opened this issue Apr 18, 2024 · 1 comment · Fixed by #20221
Assignees
Labels
area:experimental:cc Capture checking related itype:bug

Comments

@Linyxus
Copy link
Contributor

Linyxus commented Apr 18, 2024

Compiler version

main

Minimized code

import language.experimental.captureChecking

def foo[A, B](f: Any => Any, a: A): () ->{f} Unit = () =>
  val g = f.asInstanceOf[A => B]
  g(a)

Output

-- Error: issues/collectImpl.scala:4:24 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 |  val g = f.asInstanceOf[A => B]
  |          ^^^^^^^^^^^^^^^^^^^^^^
  |          reference (caps.cap : caps.Cap) is not included in the allowed capture set {f}
  |          of an enclosing function literal with expected type () ->{f} Unit
1 error found

Expectation

It should have compiled.

@Linyxus Linyxus added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 18, 2024
@Linyxus Linyxus self-assigned this Apr 18, 2024
@Linyxus Linyxus added area:experimental:cc Capture checking related and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 18, 2024
@Linyxus
Copy link
Contributor Author

Linyxus commented Apr 18, 2024

It is minimised from the failing stdlib-cc file in #20221.

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.

1 participant