diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 98491884a06f..8bad39e71a7c 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -535,8 +535,10 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma private def getGenericSignature(sym: Symbol, owner: Symbol, memberTpe: Type)(implicit ctx: Context): Option[String] = if (needsGenericSignature(sym)) { - val erasedTypeSym = sym.denot.info.typeSymbol + val erasedTypeSym = TypeErasure.fullErasure(sym.denot.info).typeSymbol if (erasedTypeSym.isPrimitiveValueClass) { + // Suppress signatures for symbols whose types erase in the end to primitive + // value types. This is needed to fix #7416. None } else { val jsOpt = GenericSignatures.javaSig(sym, memberTpe) diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index 70ecc04a6e22..700fe6134940 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -147,6 +147,12 @@ object TypeErasure { def valueErasure(tp: Type)(implicit ctx: Context): Type = erasureFn(isJava = false, semiEraseVCs = true, isConstructor = false, wildcardOK = false)(tp)(erasureCtx) + /** Like value class erasure, but value classes erase to their underlying type erasure */ + def fullErasure(tp: Type)(implicit ctx: Context): Type = + valueErasure(tp) match + case ErasedValueType(_, underlying) => erasure(underlying) + case etp => etp + def sigName(tp: Type, isJava: Boolean)(implicit ctx: Context): TypeName = { val normTp = tp.underlyingIfRepeated(isJava) val erase = erasureFn(isJava, semiEraseVCs = false, isConstructor = false, wildcardOK = true) diff --git a/compiler/src/dotty/tools/dotc/transform/CapturedVars.scala b/compiler/src/dotty/tools/dotc/transform/CapturedVars.scala index 37eebce9ac55..a8a93791ab3b 100644 --- a/compiler/src/dotty/tools/dotc/transform/CapturedVars.scala +++ b/compiler/src/dotty/tools/dotc/transform/CapturedVars.scala @@ -23,7 +23,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase = /** the following two members override abstract members in Transform */ val phaseName: String = "capturedVars" - private var Captured: Store.Location[collection.Set[Symbol]] = _ + private[this] var Captured: Store.Location[collection.Set[Symbol]] = _ private def captured(implicit ctx: Context) = ctx.store(Captured) override def initContext(ctx: FreshContext): Unit = @@ -82,7 +82,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase = */ def refClass(cls: Symbol, isVolatile: Boolean)(implicit ctx: Context): Symbol = { val refMap = if (isVolatile) refInfo.volatileRefClass else refInfo.refClass - if (cls.isClass) + if (cls.isClass) refMap.getOrElse(cls, refMap(defn.ObjectClass)) else refMap(defn.ObjectClass) }