diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-25 13:25:06 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-11 06:38:11 +0200 |
commit | 543ff7f4123ded7172fd6ede59f09945efd7c158 (patch) | |
tree | 1c14165b391ca2b6de15f5a584fc804474ada13e /src/dotty/tools/dotc/core/SymDenotations.scala | |
parent | 167581469779cabc7138427d506a16507369cbf5 (diff) | |
download | dotty-543ff7f4123ded7172fd6ede59f09945efd7c158.tar.gz dotty-543ff7f4123ded7172fd6ede59f09945efd7c158.tar.bz2 dotty-543ff7f4123ded7172fd6ede59f09945efd7c158.zip |
Make changeOwner more robust regarding non-standard owner chains
The problem is running changeOwner(from, to) where
- from is a ValDef or a Label
- an embedded definition has as owner not `from` but some
owner of `from`.
We allow such denomrlaized owners and the pattern matcher generates
them. This patch makes changeOwner take these situations into account.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 12a08a112..d0053e679 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -279,8 +279,8 @@ object SymDenotations { do { owner = owner.owner sep += separator - } while (!owner.isClass) - val fn = owner.skipPackageObject.fullNameSeparated(separator) ++ sep ++ name + } while (!owner.isClass && !owner.isPackageObject) + val fn = owner.fullNameSeparated(separator) ++ sep ++ name if (isType) fn.toTypeName else fn.toTermName } @@ -562,6 +562,15 @@ object SymDenotations { result } + /** Symbol is an owner that would be skipped by effectiveOwner. Skipped are + * - package objects + * - labels + * - non-lazy valdefs + */ + def isWeakOwner(implicit ctx: Context): Boolean = + isPackageObject || + isTerm && !is(MethodOrLazy, butNot = Label) && !isLocalDummy + // def isOverridable: Boolean = !!! need to enforce that classes cannot be redefined // def isSkolem: Boolean = ??? @@ -625,14 +634,12 @@ object SymDenotations { } } - /** If this is a package object or its implementing class, its owner, - * otherwise the denoting symbol. - */ - final def skipPackageObject(implicit ctx: Context): Symbol = - if (isPackageObject) owner else symbol + /** If this is a weak owner, its owner, otherwise the denoting symbol. */ + final def skipWeakOwner(implicit ctx: Context): Symbol = + if (isWeakOwner) owner.skipWeakOwner else symbol - /** The owner, skipping package objects. */ - final def effectiveOwner(implicit ctx: Context) = owner.skipPackageObject + /** The owner, skipping package objects, labels and non-lazy valdefs. */ + final def effectiveOwner(implicit ctx: Context) = owner.skipWeakOwner /** The class containing this denotation. * If this denotation is already a class, return itself |