diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-13 16:37:06 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-09-13 17:59:06 +0200 |
commit | 5634dcc1490de05dbf5b3f2637a7e0eb4be8d6d0 (patch) | |
tree | 3ba58f946ecb4efcef86a25cfdc52bc7b0cffab6 /src/dotty/tools/dotc/core/Symbols.scala | |
parent | 2317764b683fe548f7c5e3b5ee5ede9760433c61 (diff) | |
download | dotty-5634dcc1490de05dbf5b3f2637a7e0eb4be8d6d0.tar.gz dotty-5634dcc1490de05dbf5b3f2637a7e0eb4be8d6d0.tar.bz2 dotty-5634dcc1490de05dbf5b3f2637a7e0eb4be8d6d0.zip |
Better TreeTypeMaps
1. They now keep track of changed constructors in templates, updating
the class scope as for other members.
2. Any changed members are now entered into the new class scope at exactly
the same position as the old one. That ensures that things like caseAccessors
still work.
3. ChangeOwners now is reflected in the prefixes of any named types.
4. Newly created classes now get their own ClassInfo type.
5. TreeTypeMaps always crete "fresh" symbols. Fresh symbols do not share
a NamedType reference with an existing reference to some other symbol.
This obviates b2e0e7b4, which will be reverted.
To make it work, the interface of TreeMap changed from an ownerMap function
to a substitution-like data structure working with two lists.
Diffstat (limited to 'src/dotty/tools/dotc/core/Symbols.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 96819f627..0174f75cf 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -269,7 +269,8 @@ trait Symbols { this: Context => */ def mapSymbols(originals: List[Symbol], ttmap: TreeTypeMap) = if (originals forall (sym => - (ttmap.mapType(sym.info) eq sym.info) && (ttmap.ownerMap(sym.owner) eq sym.owner))) + (ttmap.mapType(sym.info) eq sym.info) && + !(ttmap.oldOwners contains sym.owner))) originals else { val copies: List[Symbol] = for (original <- originals) yield @@ -285,11 +286,18 @@ trait Symbols { this: Context => } (originals, copies).zipped foreach {(original, copy) => val odenot = original.denot + val oinfo = original.info match { + case ClassInfo(pre, _, parents, decls, selfInfo) => + assert(original.isClass) + ClassInfo(pre, copy.asClass, parents, decls, selfInfo) + case oinfo => oinfo + } copy.denot = odenot.copySymDenotation( symbol = copy, - owner = ttmap1.ownerMap(odenot.owner), - info = ttmap1.mapType(odenot.info), - privateWithin = ttmap1.ownerMap(odenot.privateWithin), // since this refers to outer symbols, need not include copies (from->to) in ownermap here. + owner = ttmap1.mapOwner(odenot.owner), + initFlags = odenot.flags &~ Frozen | Fresh, + info = ttmap1.mapType(oinfo), + privateWithin = ttmap1.mapOwner(odenot.privateWithin), // since this refers to outer symbols, need not include copies (from->to) in ownermap here. annotations = odenot.annotations.mapConserve(ttmap1.apply)) } copies @@ -362,6 +370,9 @@ object Symbols { final def asType(implicit ctx: Context): TypeSymbol = { assert(isType, s"isType called on not-a-Type $this"); asInstanceOf[TypeSymbol] } final def asClass: ClassSymbol = asInstanceOf[ClassSymbol] + final def isFresh(implicit ctx: Context) = + lastDenot != null && (lastDenot is Fresh) + /** Special cased here, because it may be used on naked symbols in substituters */ final def isStatic(implicit ctx: Context): Boolean = lastDenot != null && denot.isStatic |