Skip to content

Commit 5d67d90

Browse files
committed
Generate signature for forwarders
1 parent f68d5aa commit 5d67d90

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
@@ -537,6 +537,20 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
537537
}
538538
}
539539

540+
def getStaticForwarderGenericSignature(sym: Symbol, moduleClass: Symbol): String = {
541+
// scala/bug#3452 Static forwarder generation uses the same erased signature as the method if forwards to.
542+
// By rights, it should use the signature as-seen-from the module class, and add suitable
543+
// primitive and value-class boxing/unboxing.
544+
// But for now, just like we did in mixin, we just avoid writing a wrong generic signature
545+
// (one that doesn't erase to the actual signature). See run/t3452b for a test case.
546+
547+
val memberTpe = ctx.atPhase(ctx.erasurePhase) { implicit ctx => moduleClass.denot.thisType.memberInfo(sym) }
548+
val erasedMemberType = TypeErasure.erasure(memberTpe)
549+
if (erasedMemberType =:= sym.denot.info)
550+
getGenericSignature(sym, moduleClass, memberTpe).orNull
551+
else null
552+
}
553+
540554
private def getGenericSignature(sym: Symbol, owner: Symbol, memberTpe: Type)(implicit ctx: Context): Option[String] =
541555
if (needsGenericSignature(sym)) {
542556
val erasedTypeSym = sym.denot.info.typeSymbol
@@ -558,7 +572,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
558572
None
559573
}
560574

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

563576

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

0 commit comments

Comments
 (0)