You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.ClassCastException:classscala.runtime.BoxedUnit cannot be cast to classjava.lang.Integer (scala.runtime.BoxedUnit is in unnamed module of loader java.net.URLClassLoader@5eefa415; java.lang.Integer is in module java.base of loader 'bootstrap')
Expectation
Should print "ok".
Should behave the same as when unannotated or annotated with result of manually applying type alias to parameters:
This problem did not occur in Scala 3.1.x, and I first observed it in Scala 3.2.0.
The problem seems to occur only for Tuple2 and 2-ary type aliases.
The problem occurs for two, not necessary equal, integer-based actual type parameters: Boolean, Char, Int, Long
It doesn't matter what the concrete tuple element types are, as long as at least one of them is different from the corresponding actual type parameter.
It doesn't make a difference if the type parameters are actually used, e.g.,
typeListNodeF[H, T] = (H, Option[T])
The text was updated successfully, but these errors were encountered:
Looks like a problem in compiler/src/dotty/tools/dotc/transform/SpecializeTuples.scala:40
bishabosha
changed the title
2-ary type alias for Tuple2 can cause ClassCastException (confusion between type parameter and element type of tuple)
Tuple specialisation doesn't correctly see type
Oct 16, 2023
Compiler version
Welcome to Scala 3.3.1 (17.0.8.1, Java OpenJDK 64-Bit Server VM).
Minimized code
Output
Expectation
Additional observations
The text was updated successfully, but these errors were encountered: