Skip to content

Commit 43ca070

Browse files
committed
Emit generic signature for static forwarders to nullary methods
1 parent cbb1e07 commit 43ca070

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
926926
// (one that doesn't erase to the actual signature). See run/t3452b for a test case.
927927

928928
val memberTpe = atPhase(erasurePhase) { moduleClass.denot.thisType.memberInfo(sym) }
929-
val erasedMemberType = TypeErasure.fullErasure(memberTpe)
929+
val erasedMemberType = TypeErasure.transformInfo(sym, memberTpe)
930930
if (erasedMemberType =:= sym.denot.info)
931931
getGenericSignatureHelper(sym, moduleClass, memberTpe).orNull
932932
else null

compiler/src/dotty/tools/dotc/core/TypeErasure.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
697697
// See doc comment for ElimByName for speculation how we could improve this.
698698
else
699699
MethodType(Nil, Nil,
700-
eraseResult(sym.info.finalResultType.translateFromRepeated(toArray = sourceLanguage.isJava)))
700+
eraseResult(rt.translateFromRepeated(toArray = sourceLanguage.isJava)))
701701
case tp1: PolyType =>
702702
eraseResult(tp1.resultType) match
703703
case rt: MethodType => rt

tests/pos/i10347/A_1.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
trait L[+T] { def head: T }
2+
object A {
3+
def foo: L[String] = ???
4+
}

tests/pos/i10347/C_2.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public class C_2 {
2+
String hi = A.foo().head();
3+
}

0 commit comments

Comments
 (0)