forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Static forwarders for bridges lead to ambiguous errors in some Java compilers, and the trait setters aren't meant to be called by users. Since we can't remove them without breaking binary-compatibility, we mark them ACC_SYNTHETIC so that Java compilers will ignore them. See also the discussion in scala#12767 which implements an alternate fix. Fixes scala#12753. Co-Authored-By: Lukas Rytz <[email protected]>
- Loading branch information
Showing
5 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ typeclass-derivation3.scala | |
varargs-abstract | ||
zero-arity-case-class.scala | ||
i12194.scala | ||
i12753 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
1 | ||
Dbr | ||
1 | ||
1 | ||
2 | ||
1 | ||
1 | ||
1 | ||
1 | ||
2 | ||
1 | ||
1 | ||
synthetic public static C D.foo(int) | ||
public static D D.foo(int) | ||
public static D D.t() | ||
synthetic public static java.lang.Object D.bar() | ||
public static java.lang.String D.bar() | ||
public static int O.a() | ||
public static int O.b() | ||
public static int O.c() | ||
public static int O.d() | ||
public static int O.i() | ||
public static int O.j() | ||
public static int O.k() | ||
public static int O.l() | ||
synthetic public static void O.T$_setter_$a_$eq(int) | ||
public static void O.b_$eq(int) | ||
public static void O.j_$eq(int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
trait C[This <: C[This]] | ||
|
||
trait COps[This <: C[This]] { | ||
def t: This | ||
def foo(x: Int): This = t | ||
def bar: Object = "Cbr" | ||
} | ||
|
||
class D extends C[D] { | ||
def x = 1 | ||
} | ||
object D extends COps[D] { | ||
def t = new D | ||
override def foo(x: Int): D = super.foo(x) | ||
override def bar: String = "Dbr" | ||
} | ||
|
||
trait T { | ||
val a = 1 | ||
var b = 1 | ||
lazy val c = 1 | ||
def d = 1 | ||
|
||
val i: Int | ||
var j: Int | ||
lazy val k: Int = 1 | ||
def l: Int | ||
} | ||
object O extends T { | ||
val i: Int = 1 | ||
var j: Int = 1 | ||
override lazy val k: Int = 1 | ||
def l: Int = 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
public class Test { | ||
public static void s(Object s) { | ||
System.out.println(s); | ||
} | ||
|
||
public static void statics(Class<?> c) { | ||
java.lang.reflect.Method[] ms = c.getDeclaredMethods(); | ||
java.util.Arrays.sort(ms, (a, b) -> a.toString().compareTo(b.toString())); | ||
for (java.lang.reflect.Method a : ms) { | ||
if (java.lang.reflect.Modifier.isStatic(a.getModifiers())) | ||
s((a.isSynthetic() ? "synthetic " : "") + a); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
s(D.foo(1).x()); | ||
s(D.bar().trim()); | ||
|
||
s(O.a()); | ||
s(O.b()); | ||
O.b_$eq(2); | ||
s(O.b()); | ||
s(O.c()); | ||
s(O.d()); | ||
|
||
s(O.i()); | ||
s(O.j()); | ||
O.j_$eq(2); | ||
s(O.j()); | ||
s(O.k()); | ||
s(O.l()); | ||
|
||
statics(D.class); | ||
statics(O.class); | ||
} | ||
} |