diff --git a/compiler/src/dotty/tools/dotc/transform/Constructors.scala b/compiler/src/dotty/tools/dotc/transform/Constructors.scala index 9df98292fe84..1c4f93bbbf2e 100644 --- a/compiler/src/dotty/tools/dotc/transform/Constructors.scala +++ b/compiler/src/dotty/tools/dotc/transform/Constructors.scala @@ -15,6 +15,7 @@ import Symbols.* import Decorators.* import DenotTransformers.* import collection.mutable +import Types.* object Constructors { val name: String = "constructors" @@ -193,10 +194,14 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase = override def transform(tree: Tree)(using Context) = tree match { case Apply(fn, Nil) if (fn.symbol.is(OuterAccessor) - || fn.symbol.isGetter && fn.symbol.name == nme.OUTER - ) && - fn.symbol.info.resultType.classSymbol == outerParam.info.classSymbol => + || fn.symbol.isGetter && fn.symbol.name == nme.OUTER + ) && + fn.symbol.info.resultType.classSymbol == outerParam.info.classSymbol => ref(outerParam) + case Assign(lhs, rhs) if lhs.symbol.name == nme.OUTER => // not transform LHS of assignment to $outer field + cpy.Assign(tree)(lhs, super.transform(rhs)) + case dd: DefDef if dd.name.endsWith(nme.OUTER.asSimpleName) => // not transform RHS of outer accessor + dd case tree: RefTree if tree.symbol.is(ParamAccessor) && tree.symbol.name == nme.OUTER => ref(outerParam) case _ =>