Skip to content

Commit dc52f84

Browse files
committed
Don't always hoist super arguments referring to outer classes
1 parent 0265439 commit dc52f84

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

compiler/src/dotty/tools/dotc/transform/HoistSuperArgs.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,18 @@ class HoistSuperArgs extends MiniPhase with IdentityDenotTransformer { thisPhase
107107

108108
/** Type of a reference implies that it needs to be hoisted */
109109
def refNeedsHoist(tp: Type): Boolean = tp match {
110-
case tp: ThisType => !tp.cls.isStaticOwner && tp.cls != cls
110+
case tp: ThisType => !tp.cls.isStaticOwner && !cls.isContainedIn(tp.cls)
111111
case tp: TermRef => refNeedsHoist(tp.prefix)
112112
case _ => false
113113
}
114114

115115
/** Super call argument is complex, needs to be hoisted */
116-
def needsHoist(tree: Tree) = tree match {
116+
def needsHoist(tree: Tree) = tree match
117117
case _: DefDef => true
118118
case _: Template => true
119119
case _: New => !tree.tpe.typeSymbol.isStatic
120120
case _: RefTree | _: This => refNeedsHoist(tree.tpe)
121121
case _ => false
122-
}
123122

124123
/** Only rewire types that are owned by the current Hoister and is an param or accessor */
125124
def needsRewire(tp: Type) = tp match {

0 commit comments

Comments
 (0)