Skip to content

Fix #7416: Don't emit signatures of fields of primitive types #7417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there some decision about mixing significant indentation syntax with braces syntax? (this match has no braces)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently use indentation syntax for all code I touch to get a better feeling for it. If we decide not to do indentation, we can rewrite to braces automatically.

The reason not to convert to indentation wholesale is that is would destroy commit history.

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)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/CapturedVars.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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)
}
Expand Down