diff options
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Scopes.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 31 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 27 |
5 files changed, 49 insertions, 23 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 3d3a10d8e..95ad16b54 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -66,7 +66,7 @@ class Definitions(implicit ctx: Context) { lazy val AnyRefAlias: TypeSymbol = { val anyRef = ctx.newSymbol( ScalaPackageClass, tpnme.AnyRef, EmptyFlags, TypeAlias(ObjectClass.typeConstructor)) - ScalaPackageClass.preCompleteDecls.openForMutations.enter(anyRef) + ScalaPackageClass.preCompleteDecls.openForMutations.enter(anyRef) // @@@ ScalaPackageClass.enter(anyRef, ScalaPackageClass.preCompleteDecls) anyRef } lazy val AnyClass: ClassSymbol = ctx.newCompleteClassSymbol( diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala index f8147c8f0..f3fde7209 100644 --- a/src/dotty/tools/dotc/core/Scopes.scala +++ b/src/dotty/tools/dotc/core/Scopes.scala @@ -108,7 +108,7 @@ object Scopes { syms } - /** Cast this scope to a mutable scope */ + /** Cast this scope to a mutable scope @@@ */ final def openForMutations: MutableScope = this.asInstanceOf[MutableScope] final def toText(implicit ctx: Context): Text = ctx.toText(this) diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 7b4f215b5..3a6737403 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -44,6 +44,8 @@ object SymDenotations { initInfo: Type, initPrivateWithin: Symbol = NoSymbol) extends SingleDenotation { + //assert(symbol.id != 4940, name) + // ------ Getting and setting fields ----------------------------- private[this] var _flags: FlagSet = adaptFlags(initFlags) @@ -777,9 +779,14 @@ object SymDenotations { * Note: We require that this does not happen after the first time * someone does a findMember on a subclass. */ - def enter(sym: Symbol)(implicit ctx: Context) = { + def enter(sym: Symbol, scope: Scope = EmptyScope)(implicit ctx: Context) = { require(!(this is Frozen)) - info.decls.openForMutations.enter(sym) + val mscope = scope match { + case scope: MutableScope => scope + case _ => info.decls.asInstanceOf[MutableScope] + } + mscope.enter(sym) + if (_memberFingerPrint != FingerPrint.empty) memberFingerPrint.include(sym.name) if (_memberCache != null) @@ -792,7 +799,7 @@ object SymDenotations { */ def delete(sym: Symbol)(implicit ctx: Context) = { require(!(this is Frozen)) - info.decls.openForMutations.unlink(sym) + info.decls.asInstanceOf[MutableScope].unlink(sym) if (_memberFingerPrint != FingerPrint.empty) computeMemberFingerPrint if (_memberCache != null) @@ -815,19 +822,19 @@ object SymDenotations { private def computeMembersNamed(name: Name)(implicit ctx: Context): PreDenotation = if (!classSymbol.hasChildren || (memberFingerPrint contains name)) { val ownDenots = info.decls.denotsNamed(name) -// if (name.toString == "GenericCanBuildFrom") // DEBUG -// println(s"$this.member(GenericCanBuildFrom), ownDenots = $ownDenots") + if (debugTrace) // DEBUG + println(s"$this.member($name), ownDenots = $ownDenots") def collect(denots: PreDenotation, parents: List[TypeRef]): PreDenotation = parents match { case p :: ps => val denots1 = p.symbol.denot match { case parentd: ClassDenotation => -// if (name.toString == "GenericCanBuildFrom") { // DEBUG -// val s1 = parentd.membersNamed(name) -// val s2 = s1.filterExcluded(Private) -// val s3 = s2.asSeenFrom(thisType) -// val s4 = s3.filterDisjoint(ownDenots) -// println(s"$this.member(GenericCanBuildFrom) $s1 $s2 $s3 $s4") -// } + if (debugTrace) { // DEBUG + val s1 = parentd.membersNamed(name) + val s2 = s1.filterExcluded(Private) + val s3 = s2.asSeenFrom(thisType) + val s4 = s3.filterDisjoint(ownDenots) + println(s"$this.member($name) $s1 $s2 $s3 $s4") + } denots union parentd.membersNamed(name) .filterExcluded(Private) diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 38da0ce9c..c19b0e387 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -165,7 +165,8 @@ trait TypeOps { this: Context => * to a list of typerefs, by converting all refinements to member * definitions in scope `decls`. Can add members to `decls` as a side-effect. */ - def normalizeToRefs(parents: List[Type], cls: ClassSymbol, decls: MutableScope): List[TypeRef] = { + def normalizeToRefs(parents: List[Type], cls: ClassSymbol, decls: MutableScope /*@@@*/): List[TypeRef] = { + // println(s"normalizing $parents of $cls in ${cls.owner}") // !!! DEBUG var refinements = Map[TypeName, Type]() var formals = Map[TypeName, Symbol]() def normalizeToRef(tp: Type): TypeRef = tp match { @@ -183,12 +184,13 @@ trait TypeOps { this: Context => throw new TypeError(s"unexpected parent type: $tp") } val parentRefs = parents map normalizeToRef - for ((name, tpe) <- refinements) decls.enter { + for ((name, tpe) <- refinements) { val formal = formals(name) val bounds = tpe //.toRHS(formal) assert(decls.lookup(name) == NoSymbol, // DEBUG - s"redefinition of ${decls.lookup(name).debugString} in ${cls.debugString}") - ctx.newSymbol(cls, name, formal.flags & RetainedTypeArgFlags, bounds) + s"redefinition of ${decls.lookup(name).debugString} in ${cls.showLocated}") + val sym = ctx.newSymbol(cls, name, formal.flags & RetainedTypeArgFlags, bounds) + decls.enter(sym) // @@@ cls.enter(sym, decls) } parentRefs } diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index 844ddd775..982cbd622 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -29,7 +29,7 @@ object UnPickler { } /** Temporary type for classinfos, will be decomposed on completion of the class */ - case class TempClassInfoType(parentTypes: List[Type], decls: MutableScope, clazz: Symbol) extends UncachedGroundType + case class TempClassInfoType(parentTypes: List[Type], decls: /*@@@*/MutableScope, clazz: Symbol) extends UncachedGroundType /** Convert temp poly type to some native Dotty idiom. * @param forSym The symbol that gets the converted type as info. @@ -108,7 +108,7 @@ object UnPickler { for (tparam <- tparams) { val tsym = decls.lookup(tparam.name) if (tsym.exists) tsym.setFlag(TypeParam) - else decls.enter(tparam) + else decls.enter(tparam) // @@@ denot.enter(tparam, decls) } var ost = optSelfType if (ost == NoType && (denot is ModuleClass)) @@ -422,7 +422,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: || ((sym is TypeParam) && !sym.owner.isClass) || isRefinementClass(sym) ) - ) symScope(sym.owner).openForMutations.enter(sym) + ) symScope(sym.owner).openForMutations.enter(sym) // @@@ sym.owner.asClass.enter(sym, symScope(sym.owner)) sym } @@ -591,8 +591,25 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: case CONSTANTtpe => ConstantType(readConstantRef()) case TYPEREFtpe => - val pre = readTypeRef() + var pre = readTypeRef() val sym = readSymbolRef() + pre match { + case ThisType(cls) => + // The problem is that class references super.C get pickled as + // this.C. Dereferencing the member might then get an overriding class + // instance. The problem arises for instance for LinkedHashMap#MapValues + // and also for the inner Transform class in all views. We fix it by + // replacing the this with the appropriate super. + if (sym.owner != cls) { + val overriding = cls.preCompleteDecls.lookup(sym.name) + if (overriding.exists && overriding != sym) { + val base = pre.baseType(sym.owner) + assert(base.exists) + pre = SuperType(pre, base) + } + } + case _ => + } val tycon = if (isLocal(sym)) { TypeRef( @@ -626,7 +643,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: } case CLASSINFOtpe => val clazz = readSymbolRef() - TempClassInfoType(until(end, readTypeRef), symScope(clazz).openForMutations, clazz) + TempClassInfoType(until(end, readTypeRef), symScope(clazz).openForMutations /*@@@*/, clazz) case METHODtpe | IMPLICITMETHODtpe => val restpe = readTypeRef() val params = until(end, readSymbolRef) |