diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-05-08 16:19:53 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-05-08 16:19:53 +0200 |
commit | 8f05dd93a3d2a4e29e22023d5b1a62d77b88cc89 (patch) | |
tree | 1b122c24c9cca0bb96b578a8b1fe0d0ce6d5e52e | |
parent | 338dcfa80cd5ecff0cb4a961ba8eabf061fc7f12 (diff) | |
download | dotty-8f05dd93a3d2a4e29e22023d5b1a62d77b88cc89.tar.gz dotty-8f05dd93a3d2a4e29e22023d5b1a62d77b88cc89.tar.bz2 dotty-8f05dd93a3d2a4e29e22023d5b1a62d77b88cc89.zip |
LazyVals: inject Offset definitions in Template.
Otherwise Constructors is not able to see them and they get lost.
-rw-r--r-- | src/dotty/tools/dotc/transform/LazyVals.scala | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/transform/LazyVals.scala b/src/dotty/tools/dotc/transform/LazyVals.scala index 27625085f..925646ca5 100644 --- a/src/dotty/tools/dotc/transform/LazyVals.scala +++ b/src/dotty/tools/dotc/transform/LazyVals.scala @@ -59,20 +59,20 @@ class LazyVals extends MiniPhaseTransform with IdentityDenotTransformer { } } - /** Append offset fields to companion objects - */ - override def transformTypeDef(tree: TypeDef)(implicit ctx: Context, info: TransformerInfo): Tree = { - if (!tree.symbol.isClass) tree - else { - appendOffsetDefs.get(tree.symbol) match { - case None => tree - case Some(data) => - val template = tree.rhs.asInstanceOf[Template] - val newTemplate = cpy.Template(template)(body = data.defs ::: template.body) - cpy.TypeDef(tree)(rhs = newTemplate) //(ctx.withMode(Mode.FutureDefsOK)) - } - } + + /** Append offset fields to companion objects + */ + override def transformTemplate(template: tpd.Template)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = { + val cls = ctx.owner.asClass + + appendOffsetDefs.get(cls) match { + case None => template + case Some(data) => + cpy.Template(template)(body = data.defs ::: template.body) } + + } + /** Replace a local lazy val inside a method, * with a LazyHolder from * dotty.runtime(eg dotty.runtime.LazyInt) |