-
Notifications
You must be signed in to change notification settings - Fork 22
eclipse java compiler gets confused by the new ACC_BRIDGE flag in forwarders #11271
Copy link
Copy link
Closed
Description
This bug affects Akka users that write Java code in eclipse. They get error messages in the IDE ("The method get(ActorSystem) is ambiguous").
To reproduce, download ecj-4.9.jar from http://download.eclipse.org/eclipse/downloads/drops4/R-4.9-201809060745/#JDTCORE
T.scala
class A[T] {
def get: T = ???
}
object T extends A[String] {
override def get: String = "hi"
}Test.java
public class Test {
public static void main(String[] args) {
System.out.println(T.get());
}
}With 2.12.6:
$> ~/scala/scala-2.12.6/bin/scalac T.scala
$> javac -version
javac 1.8.0_172
$> javac -cp . Test.java
$> java -jar ~/Downloads/ecj-4.9.jar -8 -cp . Test.java
$>
2.12.6 generates the following static methods in T.class:
// access flags 0x9
public static get()Ljava/lang/String;
// access flags 0x9
public static get()Ljava/lang/Object;
With 2.12.7 and current 2.12.x (2.12.8-bin-25c7215):
$> ../build/quick/bin/scalac T.scala
$> javac -cp . Test.java
$> java -jar ~/Downloads/ecj-4.9.jar -8 -cp . Test.java
----------
1. ERROR in /Users/luc/scala/scala12/sandbox/Test.java (at line 3)
System.out.println(T.get());
^^^
The method get() is ambiguous for the type T
----------
1 problem (1 error)
$>
Generated methods in T.class:
// access flags 0x49
public static bridge get()Ljava/lang/Object;
// access flags 0x9
public static get()Ljava/lang/String;
The bytecode change is exactly as intended by PR scala/scala#7035 that went to 2.12.7. The follow-up PR scala/scala#7383 that went into 2.12.x fixes a different bug and does not change anything here.
Someone predicted that something like this could happen.
Reactions are currently unavailable