diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-10 18:41:03 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-10 18:41:03 +0100 |
commit | df5fcefac142f6ab65a93c33ec9179380025a492 (patch) | |
tree | 230e5a5d26ef22f3fb61be3fdbdf5c87d5271caf /src | |
parent | 9ae558a7a7060ac7dfc6ef3fc482e8eda66d33e3 (diff) | |
download | dotty-df5fcefac142f6ab65a93c33ec9179380025a492.tar.gz dotty-df5fcefac142f6ab65a93c33ec9179380025a492.tar.bz2 dotty-df5fcefac142f6ab65a93c33ec9179380025a492.zip |
Fix and simplify initializer
Initializer was needlessly complex and did not work anymore
for lazy vals (for them, we implicitly made use of the fact that
the initializer would find the symbol itself. But after name
mangling that logic would break down.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/transform/Mixin.scala | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/dotty/tools/dotc/transform/Mixin.scala b/src/dotty/tools/dotc/transform/Mixin.scala index fc82caf65..3ec2aedcb 100644 --- a/src/dotty/tools/dotc/transform/Mixin.scala +++ b/src/dotty/tools/dotc/transform/Mixin.scala @@ -112,17 +112,19 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform => sym private def initializer(sym: Symbol)(implicit ctx: Context): TermSymbol = { - val initName = if(!sym.is(Lazy)) InitializerName(sym.name.asTermName) else sym.name.asTermName - sym.owner.info.decl(initName).suchThat(_.is(Lazy) == sym.is(Lazy)).symbol - .orElse( - ctx.newSymbol( - sym.owner, - initName, - Protected | Synthetic | Method, - sym.info, - coord = sym.symbol.coord).enteredAfter(thisTransform)) - .asTerm - } + if (sym is Lazy) sym + else { + val initName = InitializerName(sym.name.asTermName) + sym.owner.info.decl(initName).symbol + .orElse( + ctx.newSymbol( + sym.owner, + initName, + Protected | Synthetic | Method, + sym.info, + coord = sym.symbol.coord).enteredAfter(thisTransform)) + } + }.asTerm override def transformTemplate(impl: Template)(implicit ctx: Context, info: TransformerInfo) = { val cls = impl.symbol.owner.asClass |