diff options
author | Martin Odersky <odersky@gmail.com> | 2015-06-20 00:44:47 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-06-20 00:45:02 +0200 |
commit | 9a4b5e7c306eb3f1c82ace10dd62576473b1dec1 (patch) | |
tree | 9580b1faebdee6cd0a55cfba71526cb5046e3897 /src | |
parent | c093792189f49c3e72ada99ca0fdb97e4023ef78 (diff) | |
download | dotty-9a4b5e7c306eb3f1c82ace10dd62576473b1dec1.tar.gz dotty-9a4b5e7c306eb3f1c82ace10dd62576473b1dec1.tar.bz2 dotty-9a4b5e7c306eb3f1c82ace10dd62576473b1dec1.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/transform/Constructors.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/transform/Constructors.scala b/src/dotty/tools/dotc/transform/Constructors.scala index d078bab1d..3d7af6bf5 100644 --- a/src/dotty/tools/dotc/transform/Constructors.scala +++ b/src/dotty/tools/dotc/transform/Constructors.scala @@ -233,9 +233,15 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor case stats => (Nil, stats) } + val mappedSuperCalls = vparams match { + case (outerParam @ ValDef(nme.OUTER, _, _)) :: _ => + superCalls.map(mapOuter(outerParam.symbol).transform) + case _ => superCalls + } + cpy.Template(tree)( constr = cpy.DefDef(constr)( - rhs = Block(superCalls ::: copyParams ::: followConstrStats, unitLiteral)), + rhs = Block(mappedSuperCalls ::: copyParams ::: followConstrStats, unitLiteral)), body = clsStats.toList) } } |