From 98deca5e3e5e98c77b1440c8ab0d9bfd232e7357 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 21 Oct 2014 16:40:09 +0200 Subject: 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. --- src/dotty/tools/dotc/core/SymDenotations.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala') 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 = { -- cgit v1.2.3