-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Erased context of captured values #17949
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
Comments
Here is a simplified example: import scala.language.experimental.captureChecking
class A
class B
object B:
def apply[T](f: ((B^) => T)): T = f(new B())
@main def Test() =
val a = B { b =>
val a1: A^{b} = new A()
a1
}
println(s"a = $a") In version: B.apply[box A^](
{
{
def $anonfun(b: B^): A^{b} =
{
val a1: A^{b} = new A()
a1:A^{a1}
}
closure($anonfun)
}
}
) Same example in the old syntax: import scala.language.experimental.captureChecking
class A
class B
object B:
def apply[T](f: (({*} B) => T)): T = f(new B())
@main def Test() =
val a = B { b =>
val a1: {b} A = new A
a1
}
println(s"a = $a") Using the old version of compiler( B.apply[box {x$0, *} A](
{
{
def $anonfun(b: {*} B): {b} A =
{
val a1: {b} A = new A()
a1:({a1} A)
}
closure($anonfun)
}
}
) Which triggered :
It seems in this concrete example, the problem is the the type of the right hand side of |
Sorry for closing it by mistake! I reopened it. |
After changing the example to the following it will be rejected as expected: import scala.language.experimental.captureChecking
class A
class B
object B:
def apply[sealed T](f: ((B^) => T)): T = f(new B())
@main def Test() =
val a = B { b =>
val a1: A^{b} = new A()
a1
} In a newer version of CC (after #17422), we use the |
I see. Thank you Yichen! |
Thank you for help, it fixed the problem |
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.3.2-RC1-bin-20230608-0af8809-NIGHTLY
Minimized code
Output
Compiles
Compilation output (after typer)
Expectation
It probably should fail to compile similarly as with last checked version 3.3.1-RC1-bin-20230503-b8d2966-NIGHTLY
Output
The text was updated successfully, but these errors were encountered: