-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Incorrect erasure for intersection type in Java method #12586
Comments
Huh, looks like I misread https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.4, somehow I was convinced the first operand of a Java intersection had to be a class and could not be an interface, and therefore designed our intersection erasure algorithm around this (#11808). Turns out that's completely false and now that 3.0 is out it's too late to change how we do intersection erasure, so we'll have to add a special case for Java intersection erasure (but I guess that was inevitable since we can't at the same time have commutativity and match the Java erasure semantics, oh well). |
Oh man, looking at testcontainers/testcontainers-scala#177 it looks like the problem was known before 3.0.0 was out, so if only we had known about it then, we could have potentially redesigned our erasure algorithm in time, whereas now we're stuck with it until Scala 4. Sadness. |
Yep, sorry. Nobody looked at it closely until an hour ago. :-( |
When I implemented our erasure algorithm in scala#11808, I misread https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.4 and incorrectly thought that a Java intersection had to contain at least one class, and since we always erase a Scala 3 intersection containing a class to that class, I thought we could use the Scala 3 intersection algorithm to erase Java intersections. But my assumption was incorrect: a Java intersection can in fact contain only interfaces, so we need to special-case them in erasure like before. Fixes scala#12586.
Compiler version
3.0.0
Minimized code
Add dependency
"org.testcontainers" % "testcontainers" % "1.15.2"
and then try the following:The method in question is defined here.
Scala 2.13 generates the following instruction:
Scala 3.0 generates the following, which differs in the return type.
The text was updated successfully, but these errors were encountered: