Skip to content

Commit 2e2a2df

Browse files
authored
Merge pull request #7417 from dotty-staging/fix-#7416
Fix #7416: Don't emit signatures of fields of primitive types
2 parents d61769d + ebbea1a commit 2e2a2df

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,10 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
535535

536536
private def getGenericSignature(sym: Symbol, owner: Symbol, memberTpe: Type)(implicit ctx: Context): Option[String] =
537537
if (needsGenericSignature(sym)) {
538-
val erasedTypeSym = sym.denot.info.typeSymbol
538+
val erasedTypeSym = TypeErasure.fullErasure(sym.denot.info).typeSymbol
539539
if (erasedTypeSym.isPrimitiveValueClass) {
540+
// Suppress signatures for symbols whose types erase in the end to primitive
541+
// value types. This is needed to fix #7416.
540542
None
541543
} else {
542544
val jsOpt = GenericSignatures.javaSig(sym, memberTpe)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ object TypeErasure {
147147
def valueErasure(tp: Type)(implicit ctx: Context): Type =
148148
erasureFn(isJava = false, semiEraseVCs = true, isConstructor = false, wildcardOK = false)(tp)(erasureCtx)
149149

150+
/** Like value class erasure, but value classes erase to their underlying type erasure */
151+
def fullErasure(tp: Type)(implicit ctx: Context): Type =
152+
valueErasure(tp) match
153+
case ErasedValueType(_, underlying) => erasure(underlying)
154+
case etp => etp
155+
150156
def sigName(tp: Type, isJava: Boolean)(implicit ctx: Context): TypeName = {
151157
val normTp = tp.underlyingIfRepeated(isJava)
152158
val erase = erasureFn(isJava, semiEraseVCs = false, isConstructor = false, wildcardOK = true)

compiler/src/dotty/tools/dotc/transform/CapturedVars.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase =
2323
/** the following two members override abstract members in Transform */
2424
val phaseName: String = "capturedVars"
2525

26-
private var Captured: Store.Location[collection.Set[Symbol]] = _
26+
private[this] var Captured: Store.Location[collection.Set[Symbol]] = _
2727
private def captured(implicit ctx: Context) = ctx.store(Captured)
2828

2929
override def initContext(ctx: FreshContext): Unit =
@@ -82,7 +82,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase =
8282
*/
8383
def refClass(cls: Symbol, isVolatile: Boolean)(implicit ctx: Context): Symbol = {
8484
val refMap = if (isVolatile) refInfo.volatileRefClass else refInfo.refClass
85-
if (cls.isClass)
85+
if (cls.isClass)
8686
refMap.getOrElse(cls, refMap(defn.ObjectClass))
8787
else refMap(defn.ObjectClass)
8888
}

0 commit comments

Comments
 (0)