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/Scopes.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/Scopes.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Scopes.scala | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala index c8252e02e..54317a496 100644 --- a/src/dotty/tools/dotc/core/Scopes.scala +++ b/src/dotty/tools/dotc/core/Scopes.scala @@ -37,7 +37,9 @@ object Scopes { */ private final val MaxRecursions = 1000 - class ScopeEntry private[Scopes] (val name: Name, val sym: Symbol, val owner: Scope) { + class ScopeEntry private[Scopes] (val name: Name, _sym: Symbol, val owner: Scope) { + + var sym: Symbol = _sym /** the next entry in the hash bucket */ @@ -249,6 +251,18 @@ object Scopes { } } + /** Replace symbol `prev` (if it exists in current scope) by symbol `replacement`. + * @pre `prev` and `replacement` have the same name. + */ + final def replace(prev: Symbol, replacement: Symbol)(implicit ctx: Context): Unit = { + require(prev.name == replacement.name) + var e = lookupEntry(prev.name) + while (e ne null) { + if (e.sym == prev) e.sym = replacement + e = lookupNextEntry(e) + } + } + /** Lookup a symbol entry matching given name. */ override final def lookupEntry(name: Name)(implicit ctx: Context): ScopeEntry = { |