forked from scala/scala
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit mixin forwarders as bridges to avoid needing generic signatures
The compiler spends a lot of effort trying to generate correct generic signatures for mixin forwarders, but is still not correct as witnessed by scala/bug#8905 among others. However, it seems that if we just emit them with the BRIDGE flag set, both javac and ecj (the Eclipse Java Compiler) will be smart enough to go look for the signature in the overridden methods, which is exactly what we want. This means that we should be able to get rid of `cloneBeforeErasure` and related code, though that would conflict with scala#7752. Because history always repeats itself, it turns out that this used to be how mixin forwarders were emitted until fe94bc7 changed this 7 years ago. The commit only says that this "has deleterious effects since many tools ignore bridge methods" which is too vague for me to do anything about. Fixes scala/bug#8905 and probably countless others.
- Loading branch information
Showing
7 changed files
with
44 additions
and
29 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
public Category<?> C.category() | ||
public Category<scala.Tuple2> C.category1() | ||
public Category C.category() | ||
public Category C.category1() | ||
public default Category<java.lang.Object> M1.category() | ||
public default Category<scala.Tuple2> M1.category1() | ||
public static Category M1.category$(M1) | ||
public static Category M1.category1$(M1) | ||
public default Category<java.lang.Object> M2.category() | ||
public default Category<scala.Tuple2> M2.category1() | ||
public static Category M2.category$(M2) | ||
public static Category M2.category1$(M2) | ||
public static Category M2.category1$(M2) |
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,9 @@ | ||
import java.util.Comparator | ||
|
||
trait RDDLike[T] { | ||
def max(comp: Comparator[T]): T = { | ||
(1.0).asInstanceOf[T] | ||
} | ||
} | ||
|
||
class DoubleRDD extends RDDLike[java.lang.Double] { } |
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,20 @@ | ||
import java.util.Comparator; | ||
|
||
public class Test { | ||
private static class DoubleComparator implements Comparator<Double> { | ||
public int compare(Double o1, Double o2) { | ||
return o1.compareTo(o2); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
DoubleRDD rdd = new DoubleRDD(); | ||
RDDLike<Double> rddLike = rdd; | ||
|
||
// This call works fine: | ||
double rddLikeMax = rddLike.max(new DoubleComparator()); | ||
// In Scala 2.10.4, this code compiles but this call fails at runtime: | ||
// java.lang.NoSuchMethodError: DoubleRDD.max(Ljava/util/Comparator;)Ljava/lang/Double; | ||
double rddMax = rdd.max(new DoubleComparator()); | ||
} | ||
} |