Skip to content

Commit 91e69cb

Browse files
committed
Fix mapOuter to be type-preserving
Only outer references that point to the same class as the outer parameter should be mapped. Other outer references should be left alone. Such references can appear after the initial supercall of a constructor.
1 parent 9a4b5e7 commit 91e69cb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/dotty/tools/dotc/transform/Constructors.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
159159
/** Map outer getters $outer and outer accessors $A$B$$$outer to the given outer parameter. */
160160
def mapOuter(outerParam: Symbol) = new TreeMap {
161161
override def transform(tree: Tree)(implicit ctx: Context) = tree match {
162-
case Apply(fn, Nil) if fn.symbol.is(OuterAccessor) || fn.symbol.isGetter && fn.symbol.name == nme.OUTER =>
162+
case Apply(fn, Nil)
163+
if (fn.symbol.is(OuterAccessor)
164+
|| fn.symbol.isGetter && fn.symbol.name == nme.OUTER
165+
) &&
166+
fn.symbol.info.resultType.classSymbol == outerParam.info.classSymbol =>
163167
ref(outerParam)
164168
case _ =>
165169
super.transform(tree)

0 commit comments

Comments
 (0)