aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/LazyVals.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/transform/LazyVals.scala')
-rw-r--r--src/dotty/tools/dotc/transform/LazyVals.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/transform/LazyVals.scala b/src/dotty/tools/dotc/transform/LazyVals.scala
index e52e2537c..b57e4c592 100644
--- a/src/dotty/tools/dotc/transform/LazyVals.scala
+++ b/src/dotty/tools/dotc/transform/LazyVals.scala
@@ -68,11 +68,16 @@ class LazyVals extends MiniPhaseTransform with IdentityDenotTransformer {
appendOffsetDefs.get(cls) match {
case None => template
case Some(data) =>
- cpy.Template(template)(body = data.defs ::: template.body)
+ cpy.Template(template)(body = addInFront(data.defs, template.body))
}
}
+ private def addInFront(prefix: List[Tree], stats: List[Tree]) = stats match {
+ case first :: rest if isSuperConstrCall(first) => first :: prefix ::: rest
+ case _ => prefix ::: stats
+ }
+
/** Replace a local lazy val inside a method,
* with a LazyHolder from
* dotty.runtime(eg dotty.runtime.LazyInt)