Open lrytz opened 1 month ago
I'm OK with that, but:
Welcome to Scala 3.5.1 (22.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> class A { class B }
// defined class A
scala> def f(using a: A): a.type = { println("f"); a }
def f(using a: A): a.type
scala> given a[X]: A = new A
def a[X]: A
scala> new f.B
java.lang.AssertionError: assertion failed: val <none>
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.assertClassNotArray(BCodeHelpers.scala:151)
at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.assertClassNotArrayNotPrimitive(BCodeHelpers.scala:156)
at dotty.tools.backend.jvm.BCodeHelpers$BCInnerClassGen.getClassBType(BCodeHelpers.scala:174)
This can also exploited to bypass bound realizability checks:
@main def Test =
trait A:
type B >: Int <: Boolean
def f(using a: A): a.type = a
given a[X]: A = a
val _: Boolean = 1 : f.B // ClassCastException
3.5.1
Via https://discord.com/channels/632150470000902164/632628489719382036/1296041645900562455
In the quotes API it's a
transparent inline def
: https://github.com/scala/scala3/blob/3.5.1/library/src/scala/quoted/Quotes.scala#L18.@sjrd said
which makes sense; is it specced?