-
Notifications
You must be signed in to change notification settings - Fork 1.1k
erasure(Array[Int] | Array[Float]) == Array[Object] #1065
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
Array[_ <: AnyVal]
for branches of an If/Match
Errasure of ((Array[Int] | Array[Float])) is currently Array[Object]. |
Unlike arrays of objects, that can be accessed as an array of a super type of this object, int[] cannot be accessed as an array of primitives.
The lub of Int[] and Float[] is Object, not Object[]. Fixes scala#1065.
@sjrd you have two competing fixes to choose from, that do more-or-less the same in different ways. |
Both the available fixes indeed solve the original issue I was struggling with. I don't think I have the competence to choose either. If you really want my opinion, I'd vote for @DarkDimius' version, as I'm guess it would be slightly faster (it doesn't need additional subtyping checks) |
Fix #1065 erasedLub for arrays of primitives.
I minimized the bug in the problematic test
t3833.scala
from #1061 to something that does not even require aMatch
. It can be reproduced with anIf
:This causes an assertion in the back-end. We can see that the types are wrong as early as after erasure: (grep for HERE)
The complete stack trace of the error is:
The text was updated successfully, but these errors were encountered: