File tree 2 files changed +11
-1
lines changed
compiler/src/dotty/tools/dotc/transform
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import core.Decorators._
13
13
import core .StdNames .nme
14
14
import core .Names ._
15
15
import core .NameOps ._
16
+ import core .NameKinds .SuperArgName
16
17
import SymUtils ._
17
18
import dotty .tools .dotc .ast .tpd
18
19
@@ -197,10 +198,16 @@ object ExplicitOuter {
197
198
private def outerAccName (cls : ClassSymbol )(using Context ): TermName =
198
199
nme.OUTER .expandedName(cls)
199
200
201
+ private def outerOwner (sym : Symbol )(using Context ): Symbol =
202
+ val owner = sym.effectiveOwner
203
+ if owner.name.is(SuperArgName ) || owner.isLocalDummy
204
+ then owner.enclosingClass
205
+ else owner
206
+
200
207
/** Class needs an outer pointer, provided there is a reference to an outer this in it. */
201
208
def needsOuterIfReferenced (cls : ClassSymbol )(using Context ): Boolean =
202
209
! (cls.isStatic
203
- || cls.effectiveOwner .isStaticOwner
210
+ || outerOwner( cls) .isStaticOwner
204
211
|| cls.is(PureInterface )
205
212
)
206
213
Original file line number Diff line number Diff line change 1
1
class C1 (x : AnyRef ) {};
2
2
3
3
class C2 extends C1 ({ class A extends AnyRef {}; (new A ) : AnyRef }) {};
4
+
5
+ class Outer :
6
+ class C2 extends C1 ({ class A extends AnyRef {}; (new A ) : AnyRef }) {};
You can’t perform that action at this time.
0 commit comments