From 15129574ec21fb66193d183201e5caee7ff53120 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Tue, 28 Jul 2015 13:12:41 +0200 Subject: Fix lazy vals in mixin They should not become deferred. And there could be multiple symbols with same name in same scope, e.g.: implicit class Foo(){} will create implicit method Foo that and a lazy module named Foo --- src/dotty/tools/dotc/transform/Mixin.scala | 5 +++-- src/dotty/tools/dotc/transform/PatternMatcher.scala | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/transform') diff --git a/src/dotty/tools/dotc/transform/Mixin.scala b/src/dotty/tools/dotc/transform/Mixin.scala index 431d5b5e1..e405b08a0 100644 --- a/src/dotty/tools/dotc/transform/Mixin.scala +++ b/src/dotty/tools/dotc/transform/Mixin.scala @@ -98,7 +98,7 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform => override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Erasure]) override def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = - if (sym.is(Accessor, butNot = Deferred) && sym.owner.is(Trait)) + if (sym.is(Accessor, butNot = Deferred | Lazy) && sym.owner.is(Trait)) sym.copySymDenotation(initFlags = sym.flags &~ ParamAccessor | Deferred).ensureNotPrivate else if (sym.isConstructor && sym.owner.is(Trait)) sym.copySymDenotation( @@ -109,7 +109,8 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform => 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).symbol + def hasSameLaziness(s: Symbol) = if(sym.is(Lazy)) s.is(Lazy) else !s.is(Lazy) + sym.owner.info.decl(initName).suchThat(hasSameLaziness).symbol .orElse( ctx.newSymbol( sym.owner, diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala index 6a86392da..2df7a9825 100644 --- a/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -440,7 +440,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans def emitVars = storedBinders.nonEmpty - private lazy val storedSubsted = (subPatBinders, subPatRefs).zipped.partition{ case (sym, _) => storedBinders(sym) } + lazy val storedSubsted = (subPatBinders, subPatRefs).zipped.partition{ case (sym, _) => storedBinders(sym) } def stored = storedSubsted._1 -- cgit v1.2.3