Skip to content

Commit 2152bf5

Browse files
committed
Generate signature for forwarders
1 parent ced86e4 commit 2152bf5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,20 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
549549
}
550550
}
551551

552+
def getStaticForwarderGenericSignature(sym: Symbol, moduleClass: Symbol): String = {
553+
// scala/bug#3452 Static forwarder generation uses the same erased signature as the method if forwards to.
554+
// By rights, it should use the signature as-seen-from the module class, and add suitable
555+
// primitive and value-class boxing/unboxing.
556+
// But for now, just like we did in mixin, we just avoid writing a wrong generic signature
557+
// (one that doesn't erase to the actual signature). See run/t3452b for a test case.
558+
559+
val memberTpe = ctx.atPhase(ctx.erasurePhase) { implicit ctx => moduleClass.denot.thisType.memberInfo(sym) }
560+
val erasedMemberType = TypeErasure.erasure(memberTpe)
561+
if (erasedMemberType =:= sym.denot.info)
562+
getGenericSignature(sym, moduleClass, memberTpe).orNull
563+
else null
564+
}
565+
552566
private def getGenericSignature(sym: Symbol, owner: Symbol, memberTpe: Type)(implicit ctx: Context): Option[String] =
553567
if (needsGenericSignature(sym)) {
554568
val erasedTypeSym = sym.denot.info.typeSymbol
@@ -570,7 +584,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
570584
None
571585
}
572586

573-
def getStaticForwarderGenericSignature(sym: Symbol, moduleClass: Symbol): String = null // todo: implement
574587

575588

576589
def sourceFileFor(cu: CompilationUnit): String = cu.source.file.name

0 commit comments

Comments
 (0)