aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-03-23 16:45:10 +0100
committerMartin Odersky <odersky@gmail.com>2013-03-23 16:45:10 +0100
commit8ea3a4627c7dc66f65705ec9822c01a2225eacae (patch)
treee9966adbb3df29c4b458b7aaaa68b7cc8dab5a17
parent6c6f77682f95496feef72cc0ecd3ba00ccbdfa49 (diff)
downloaddotty-8ea3a4627c7dc66f65705ec9822c01a2225eacae.tar.gz
dotty-8ea3a4627c7dc66f65705ec9822c01a2225eacae.tar.bz2
dotty-8ea3a4627c7dc66f65705ec9822c01a2225eacae.zip
Attempt to fix fingerprint problem (disabled for now)
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala2
-rw-r--r--src/dotty/tools/dotc/core/Scopes.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala31
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala10
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala27
-rw-r--r--src/test/showClass.scala4
6 files changed, 52 insertions, 24 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)
diff --git a/src/test/showClass.scala b/src/test/showClass.scala
index 4866d536f..5412e25c7 100644
--- a/src/test/showClass.scala
+++ b/src/test/showClass.scala
@@ -46,7 +46,9 @@ object showClass {
// showClasses("scala.Boolean")
// showClasses("scala.Array")
// showClasses("scala.math.Ordering")
- showClasses("scala.collection.mutable.LinkedHashMap")
+// showClasses("scala.collection.JavaConversions")
+ showClasses("scala.collection.convert.Wrappers")
+ showClasses("scala.collection.mutable.WeakHashMap")
// showClasses("scala.collection.Traversable")
// showClasses("scala.collection.LinearSeqLike")
// showClasses("scala.collection.immutable.List")