Closed
Description
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.