diff options
author | Martin Odersky <odersky@gmail.com> | 2014-10-21 16:40:09 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-10-26 16:24:01 +0100 |
commit | 98deca5e3e5e98c77b1440c8ab0d9bfd232e7357 (patch) | |
tree | ad72cedaec819c41bc455e5560de0d943e63de33 /src/dotty/tools/dotc/core/SymDenotations.scala | |
parent | 04001befb1a7f08da0c38166eed61322104adbaf (diff) | |
download | dotty-98deca5e3e5e98c77b1440c8ab0d9bfd232e7357.tar.gz dotty-98deca5e3e5e98c77b1440c8ab0d9bfd232e7357.tar.bz2 dotty-98deca5e3e5e98c77b1440c8ab0d9bfd232e7357.zip |
Fix to enclosingClass
The skip logic in enclosing class worked only when the original symbol was labelled
inSuperCall. The patch makes it work also for symbols that are in turn owned by an
inSuperCall symbol. Also it treats JavaStatic terms as also not being enclosed by
the lexically enclosing class.
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 4cc15897c..ae8fceeb7 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -666,10 +666,16 @@ object SymDenotations { * for these definitions. */ final def enclosingClass(implicit ctx: Context): Symbol = { - def enclClass(d: SymDenotation): Symbol = - if (d.isClass || !d.exists) d.symbol else enclClass(d.owner) - val cls = enclClass(this) - if (this is InSuperCall) cls.owner.enclosingClass else cls + def enclClass(sym: Symbol, skip: Boolean): Symbol = { + def newSkip = sym.is(InSuperCall) || sym.is(JavaStaticTerm) + if (!sym.exists) + NoSymbol + else if (sym.isClass) + if (skip) enclClass(sym.owner, newSkip) else sym + else + enclClass(sym.owner, skip || newSkip) + } + enclClass(symbol, false) } final def isEffectivelyFinal(implicit ctx: Context): Boolean = { |