-
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
Align erasure of Array[Nothing]
and Array[Null]
with Scala 2
#22517
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,10 +53,10 @@ object Main { | |
z.c_40(dummy) | ||
z.c_41(dummy) | ||
z.c_42(dummy) | ||
z.b_43(dummy) | ||
//z.b_43(dummy) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Inspect why both these methods' erasures are wrong, or why were they considered correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
z.c_44(dummy) | ||
z.c_45(dummy) | ||
z.b_46(dummy) | ||
//z.b_46(dummy) | ||
z.c_47(dummy) | ||
// z.a_48(dummy) | ||
// z.c_49(dummy) | ||
|
@@ -101,6 +101,10 @@ object Main { | |
z.objectARRAY_88(dummy) | ||
z.objectARRAY_89(dummy) | ||
z.objectARRAY_90(dummy) | ||
z.objectARRAY_91(dummy) | ||
z.objectARRAY_92(dummy) | ||
z.objectARRAY_93(dummy) | ||
z.objectARRAY_94(dummy) | ||
|
||
val methods = classOf[scala2Lib.Z].getDeclaredMethods.toList ++ classOf[dottyApp.Z].getDeclaredMethods.toList | ||
methods.foreach { m => | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -186,4 +186,10 @@ class Z { | |||||||||
def objectARRAY_88(x: Array[Any]): Unit = {} | ||||||||||
def objectARRAY_89(x: Array[AnyRef]): Unit = {} | ||||||||||
def objectARRAY_90(x: Array[AnyVal]): Unit = {} | ||||||||||
|
||||||||||
def objectARRAY_91(x: Array[Nothing]): Unit = {} | ||||||||||
def objectARRAY_92(x: Array[Null]): Unit = {} | ||||||||||
def objectARRAY_93(x: Array[_ <: Nothing]): Unit = {} | ||||||||||
def objectARRAY_94(x: Array[_ <: Null]): Unit = {} | ||||||||||
Comment on lines
+192
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should actually be:
Suggested change
but for some reason, it passes the test locally, I will have to test it better, but my machine keeps crashing... so checking with the CI :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is weird, the CI passes while // In Scala 2
class Foo {
def a: Array[Nothing] = null
def b: Array[Null] = null
def c: Array[_ <: Nothing] = null
def s: Array[_ <: Null] = null
} // In Scala 3
@main def Test =
(new Foo).a
(new Foo).b
(new Foo).c
(new Foo).s The generated bytecode from Scala 2 is the following: Compiled from "s2.scala"
public class Foo {
public java.lang.Object[] a();
public java.lang.Object[] b();
public scala.runtime.Nothing$[] c();
public scala.runtime.Null$[] s();
public Foo();
} We can clearly see Scala 3 (this PR) emitting a call to the wrong method for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've checked a bit and throwing a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already an issue opened on sbt (sbt/sbt#6852). The proposed workaround ( |
||||||||||
|
||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workaround until #22524 is resolved