Skip to content

Commit 4eae58b

Browse files
committed
Look up members at erasure phase for generating static forwarders
Forward-ports scala/scala@b6d7e0c42c
1 parent fdbb94f commit 4eae58b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
607607
val names = tp.memberNames(takeAllFilter).toSeq.sorted
608608
val buffer = mutable.ListBuffer[Symbol]()
609609
names.foreach { name =>
610-
buffer ++= tp.memberBasedOnFlags(name, required, excluded)
610+
// lookup members at erasure: lampepfl/dotty#12753
611+
buffer ++= atPhase(erasurePhase)(tp.memberBasedOnFlags(name, required, excluded))
611612
.alternatives.sortBy(_.signature)(Signature.lexicographicOrdering).map(_.symbol)
612613
}
613614
buffer.toList

tests/run/i12753/C.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trait C[This <: C[This]]
2+
3+
trait COps[This <: C[This]] {
4+
def t: This
5+
def foo(x: Int): This = t
6+
def bar: Object = ""
7+
}
8+
9+
class D extends C[D] {
10+
def x = 1
11+
}
12+
object D extends COps[D] {
13+
def t = new D
14+
override def foo(x: Int): D = super.foo(x)
15+
override def bar: String = ""
16+
}

tests/run/i12753/Test.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public class Test {
2+
public static void main(String[] args) {
3+
if (D.foo(1).x() != 1 || !D.bar().isEmpty())
4+
throw new RuntimeException("");
5+
}
6+
}

0 commit comments

Comments
 (0)