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/SymDenotations.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/SymDenotations.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index c9777ebf6..aed55e49a 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -867,7 +867,7 @@ object SymDenotations { TermRef.withSigAndDenot(owner.thisType, name.asTermName, signature, this) def nonMemberTermRef(implicit ctx: Context): TermRef = - TermRef.withNonMemberSym(owner.thisType, name.asTermName, symbol.asTerm) + TermRef.withFixedSym(owner.thisType, name.asTermName, symbol.asTerm) /** The variance of this type parameter or type member as an Int, with * +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter @@ -1182,15 +1182,13 @@ object SymDenotations { * someone does a findMember on a subclass. * @param scope The scope in which symbol should be entered. * If this is EmptyScope, the scope is `decls`. - * @param replace Replace any existing symbol with same name. - * This is always done if this denotes a package class. */ - def enter(sym: Symbol, scope: Scope = EmptyScope, replace: Boolean = false)(implicit ctx: Context): Unit = { + def enter(sym: Symbol, scope: Scope = EmptyScope)(implicit ctx: Context): Unit = { val mscope = scope match { case scope: MutableScope => scope case _ => decls.asInstanceOf[MutableScope] } - if (replace || (this is PackageClass)) { + if (this is PackageClass) { val entry = mscope.lookupEntry(sym.name) if (entry != null) { if (entry.sym == sym) return @@ -1212,6 +1210,17 @@ object SymDenotations { myMemberCache invalidate sym.name } + /** Replace symbol `prev` (if defined in current class) by symbol `replacement`. + * If `prev` is not defined in current class, do nothing. + * @pre `prev` and `replacement` have the same name. + */ + def replace(prev: Symbol, replacement: Symbol)(implicit ctx: Context): Unit = { + require(!(this is Frozen)) + decls.asInstanceOf[MutableScope].replace(prev, replacement) + if (myMemberCache != null) + myMemberCache invalidate replacement.name + } + /** Delete symbol from current scope. * Note: We require that this does not happen after the first time * someone does a findMember on a subclass. |