Skip to content

Commit 9a4b5e7

Browse files
committed
Map outer fields to parameters in primary constructor
Previously this was only done in secondary constructors; need to do it in primary constructor as well to avoid "reference to this before super" problems.
1 parent c093792 commit 9a4b5e7

File tree

5 files changed

+7
-1
lines changed

5 files changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,15 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
233233
case stats => (Nil, stats)
234234
}
235235

236+
val mappedSuperCalls = vparams match {
237+
case (outerParam @ ValDef(nme.OUTER, _, _)) :: _ =>
238+
superCalls.map(mapOuter(outerParam.symbol).transform)
239+
case _ => superCalls
240+
}
241+
236242
cpy.Template(tree)(
237243
constr = cpy.DefDef(constr)(
238-
rhs = Block(superCalls ::: copyParams ::: followConstrStats, unitLiteral)),
244+
rhs = Block(mappedSuperCalls ::: copyParams ::: followConstrStats, unitLiteral)),
239245
body = clsStats.toList)
240246
}
241247
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)