Skip to content

Type argument of asInstanceOf is boxed #20224

Closed
@Linyxus

Description

@Linyxus

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions