diff options
author | Martin Odersky <odersky@gmail.com> | 2014-06-18 19:15:41 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-07-17 11:01:58 +0200 |
commit | d8864d36e07e1343fc623250b72fdd590c84e732 (patch) | |
tree | 4277d5d672273eaed0d2688bfc4f2f8fcf502e2c /src/dotty/tools/dotc/core | |
parent | bdbed3934affb22095771c0a4858759a8b813f23 (diff) | |
download | dotty-d8864d36e07e1343fc623250b72fdd590c84e732.tar.gz dotty-d8864d36e07e1343fc623250b72fdd590c84e732.tar.bz2 dotty-d8864d36e07e1343fc623250b72fdd590c84e732.zip |
Add cloneScope method and handle versioning of ClassInfo#decls
This is done to streamline changing class denotations in new phases
by adding to (or otherwise modifying) their decls scope.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Scopes.scala | 9 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/transform/Erasure.scala | 2 |
3 files changed, 9 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala index 367713d11..919e35a7e 100644 --- a/src/dotty/tools/dotc/core/Scopes.scala +++ b/src/dotty/tools/dotc/core/Scopes.scala @@ -18,6 +18,7 @@ import SymDenotations._ import printing.Texts._ import printing.Printer import util.common._ +import util.DotClass import SymDenotations.NoDenotation import collection.mutable.ListBuffer @@ -55,7 +56,7 @@ object Scopes { * or to delete them. These methods are provided by subclass * MutableScope. */ - abstract class Scope extends printing.Showable with Iterable[Symbol] { + abstract class Scope extends DotClass with printing.Showable with Iterable[Symbol] { /** The last scope-entry from which all others are reachable via `prev` */ private[dotc] def lastEntry: ScopeEntry @@ -77,8 +78,8 @@ object Scopes { */ def iterator: Iterator[Symbol] = toList.iterator - /** Returns a new scope with the same content as this one. */ - def cloneScope(implicit ctx: Context): Scope + /** Returns a new mutable scope with the same content as this one. */ + def cloneScope(implicit ctx: Context): MutableScope /** Is the scope empty? */ override def isEmpty: Boolean = lastEntry eq null @@ -354,7 +355,7 @@ object Scopes { override def size = 0 override def nestingLevel = 0 override def toList = Nil - override def cloneScope(implicit ctx: Context): Scope = this + override def cloneScope(implicit ctx: Context): MutableScope = unsupported("cloneScope") override def lookupEntry(name: Name)(implicit ctx: Context): ScopeEntry = null override def lookupNextEntry(entry: ScopeEntry)(implicit ctx: Context): ScopeEntry = null } diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 4885b30d8..dad88bc60 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2077,8 +2077,8 @@ object Types { if (prefix eq this.prefix) this else ClassInfo(prefix, cls, classParents, decls, selfInfo) - def derivedClassInfo(prefix: Type = this.prefix, classParents: List[TypeRef] = classParents, selfInfo: DotClass = this.selfInfo)(implicit ctx: Context) = - if ((prefix eq this.prefix) && (classParents eq this.classParents) && (selfInfo eq this.selfInfo)) this + def derivedClassInfo(prefix: Type = this.prefix, classParents: List[TypeRef] = classParents, decls: Scope = this.decls, selfInfo: DotClass = this.selfInfo)(implicit ctx: Context) = + if ((prefix eq this.prefix) && (classParents eq this.classParents) && (decls eq this.decls) && (selfInfo eq this.selfInfo)) this else ClassInfo(prefix, cls, classParents, decls, selfInfo) override def computeHash = doHash(cls, prefix) @@ -2431,7 +2431,7 @@ object Types { case self: Type => this(self) case _ => tp.self } - tp.derivedClassInfo(prefix1, parents1, self1) + tp.derivedClassInfo(prefix1, parents1, tp.decls, self1) } } diff --git a/src/dotty/tools/dotc/core/transform/Erasure.scala b/src/dotty/tools/dotc/core/transform/Erasure.scala index da14f72d1..e35cdd128 100644 --- a/src/dotty/tools/dotc/core/transform/Erasure.scala +++ b/src/dotty/tools/dotc/core/transform/Erasure.scala @@ -146,7 +146,7 @@ class Erasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wildcard if ((cls eq defn.ObjectClass) || cls.isPrimitiveValueClass) Nil else if (cls eq defn.ArrayClass) defn.ObjectClass.typeRef :: Nil else removeLaterObjects(classParents.mapConserve(eraseTypeRef)) - tp.derivedClassInfo(this(pre), parents, this(tp.selfType)) + tp.derivedClassInfo(this(pre), parents, decls, this(tp.selfType)) case NoType | NoPrefix | ErrorType => tp case tp: WildcardType if wildcardOK => |