Skip to content

Commit ab00237

Browse files
committed
javac sees better types with new mixin forwarder scheme
Thanks to mixin forwarders now being emitted as bridges, we can resolve some long-standing TODOs. I've also manually verified that this works with ecj.
1 parent 7df83bc commit ab00237

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

test/files/run/t3452d/Test.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import scala.collection.immutable.Nil;
2-
import scala.collection.immutable.List;
3-
41
public class Test {
52
public static void main(String[] args) {
63
C<String> c = new C<String>();
7-
// TODO add a bridge during mixin so we can expose
8-
// sharper generic signature for `tail`.
9-
/*Traversable<String>*/ Object ls = c.tail();
4+
scala.collection.Iterable<String> ls = c.tail();
105
}
116
}

test/files/run/t3452g/A.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ trait TraversableLike[A, Repr] {
44

55
abstract class AbstractTrav[A] extends TraversableLike[A, AbstractTrav[A]]
66

7+
class C1 extends AbstractTrav[String]
8+
79
object O extends AbstractTrav[String]
810

9-
class C[A] extends AbstractTrav[A]
11+
class C2[A] extends AbstractTrav[A]

test/files/run/t3452g/Test.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
21
public class Test {
3-
public static void main(String[] args) {
4-
// To get better types here, we would need to
5-
// add bridge during mixin so we can expose
6-
// a generic return type of Traversable<A>, because the erasure
7-
// of this (Traversable) differs from the erasure of the mixed
8-
// method (erasure(Repr) = Object)
2+
public static void main(String[] args) {
3+
AbstractTrav<String> lsSharp1 = new C1().tail();
94

10-
Object lsSharp = O.tail();
5+
// Object is the result type for the static forwarder (might be because of #11305)
6+
Object lsSharp2 = O.tail();
117

12-
Object lsSharp2 = new C<String>().tail();
13-
}
8+
AbstractTrav<String> lsSharp3 = new C2<String>().tail();
9+
}
1410
}

0 commit comments

Comments
 (0)