-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Tuple.toList.toArray raise java.lang.ClassCastException #14964
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
The source of the problem seems to be in typer while inferring the Tuple2.apply[Int, Int](1, 2).toList.toArray[(Int | (Int | Nothing))](
scala.reflect.ClassTag.apply[(Int | (Int | Nothing))](
classOf[Object]
)
) |
We get |
It seems we are not summoning the correct println(summon[reflect.ClassTag[Int]]) // classOf[Int]
println(summon[reflect.ClassTag[Int | Int]]) // classOf[Int]
println(summon[reflect.ClassTag[Int | 1]]) // classOf[Int]
println(summon[reflect.ClassTag[Int | Nothing]]) // classOf[Object] |
At line https://github.com/lampepfl/dotty/blob/main/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala#L42, Should the erasure of |
Aligns `| Nothing` with `& Any` and `Nothing |` with `Any &` for value types. This also fixes `summon[ClassTag[Int | Nothing]]` as it is now equivalent to `summon[ClassTag[Int]]`. Fixes scala#14970 Fixes scala#14964 >⚠️ This is a binary breaking change. > Previous version generated the `def f: Int` and `def f: Object` variants of the method. > In the new one, we only generate the the `def f: Int` version. > Unfortunatelly, the previous version called the boxed version of the interface which does not exist anymore. > > Is this something that we enounter in practice?
…e types. This also fixes `summon[ClassTag[Int | Nothing]]` as it is now equivalent to `summon[ClassTag[Int]]`. Fixes scala#14970 Fixes scala#14964 >⚠️ This is a binary breaking change. > the Previous version generated the `def f: Int` and `def f: Object` variants of the method. > In the new one, we only generate the `def f: Int` version. > Unfortunately, the previous version called the boxed version of the interface that does not exist anymore. > > Is this something that we encounter in practice?
…e types. This also fixes `summon[ClassTag[Int | Nothing]]` as it is now equivalent to `summon[ClassTag[Int]]`. Fixes scala#14970 Fixes scala#14964 >⚠️ This is a binary breaking change. > the Previous version generated the `def f: Int` and `def f: Object` variants of the method. > In the new one, we only generate the `def f: Int` version. > Unfortunately, the previous version called the boxed version of the interface that does not exist anymore. > > Is this something that we encounter in practice?
…e types. This also fixes `summon[ClassTag[Int | Nothing]]` as it is now equivalent to `summon[ClassTag[Int]]`. Fixes scala#14970 Fixes scala#14964 >⚠️ This is a binary breaking change. > the Previous version generated the `def f: Int` and `def f: Object` variants of the method. > In the new one, we only generate the `def f: Int` version. > Unfortunately, the previous version called the boxed version of the interface that does not exist anymore. > > Is this something that we encounter in practice?
…e types. This also fixes `summon[ClassTag[Int | Nothing]]` as it is now equivalent to `summon[ClassTag[Int]]`. Fixes scala#14970 Fixes scala#14964 >⚠️ This is a binary breaking change. > the Previous version generated the `def f: Int` and `def f: Object` variants of the method. > In the new one, we only generate the `def f: Int` version. > Unfortunately, the previous version called the boxed version of the interface that does not exist anymore. > > Is this something that we encounter in practice?
This make the erasure different for value types as they now correctly erase to the primitive types instead of `Object`. Aligns | Nothing with & Any and Nothing | with Any & for value types. This also fixes `summon[ClassTag[Int | Nothing]]` as it is now equivalent to `summon[ClassTag[Int]]`. Fixes scala#14970 Fixes scala#14964 >⚠️ This is a binary breaking change. > the Previous version generated the `def f: Int` and `def f: Object` variants of the method. > In the new one, we only generate the `def f: Int` version. > Unfortunately, the previous version called the boxed version of the interface that does not exist anymore. > > Is this something that we encounter in practice?
This make the erasure different for value types as they now correctly erase to the primitive types instead of `Object`. Aligns | Nothing with & Any and Nothing | with Any & for value types. This also fixes `summon[ClassTag[Int | Nothing]]` as it is now equivalent to `summon[ClassTag[Int]]`. Fixes scala#14970 Fixes scala#14964 >⚠️ This is a binary breaking change. > the Previous version generated the `def f: Int` and `def f: Object` variants of the method. > In the new one, we only generate the `def f: Int` version. > Unfortunately, the previous version called the boxed version of the interface that does not exist anymore. > > Is this something that we encounter in practice?
This make the erasure different for value types as they now correctly erase to the primitive types instead of `Object`. Aligns | Nothing with & Any and Nothing | with Any & for value types. This also fixes `summon[ClassTag[Int | Nothing]]` as it is now equivalent to `summon[ClassTag[Int]]`. Fixes scala#14970 Fixes scala#14964 >⚠️ This is a binary breaking change. > the Previous version generated the `def f: Int` and `def f: Object` variants of the method. > In the new one, we only generate the `def f: Int` version. > Unfortunately, the previous version called the boxed version of the interface that does not exist anymore. > > Is this something that we encounter in practice?
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
Scala 3.1.0, Scala 3.1.1, Scala 3.1.2 RC1, Scala 3.1.2
Minimized code
Output
Expectation
Both works
The text was updated successfully, but these errors were encountered: