Skip to content

Commit 652a7e5

Browse files
committed
Enclosing class skips classes from inSuperCall definitions
Syntactically enclosing class is not accessible from such definitions, so should be skipped.
1 parent 431288d commit 652a7e5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ object SymDenotations {
469469
// for not doing this outright is speed. We would like to avoid
470470
// creating a new context object each time we call accessWithin.
471471
// Note that the exception should be thrown only infrequently.
472-
case ex: NotDefinedHere => test(ctx.withMode(Mode.FutureDefsOK))
472+
case ex: NotDefinedHere => test(ctx.addMode(Mode.FutureDefsOK))
473473
}
474474
}
475475

@@ -637,8 +637,12 @@ object SymDenotations {
637637
/** The class containing this denotation.
638638
* If this denotation is already a class, return itself
639639
*/
640-
final def enclosingClass(implicit ctx: Context): Symbol =
641-
if (isClass || !exists) symbol else owner.enclosingClass
640+
final def enclosingClass(implicit ctx: Context): Symbol = {
641+
def enclClass(d: SymDenotation): Symbol =
642+
if (d.isClass || !d.exists) d.symbol else enclClass(d.owner)
643+
val cls = enclClass(this)
644+
if (this is InSuperCall) cls.owner.enclosingClass else cls
645+
}
642646

643647
final def isEffectivelyFinal(implicit ctx: Context): Boolean = {
644648
(this.flags is Flags.PrivateOrFinal) || (!this.owner.isClass) ||

0 commit comments

Comments
 (0)