aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-07-28 13:12:41 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-07-28 13:12:41 +0200
commit15129574ec21fb66193d183201e5caee7ff53120 (patch)
treed4c4850416ff0d2503a4840a406f41897c616a90 /src/dotty/tools/dotc/transform
parentf018c38f63de548a885723e46c6c726b0cbe2c54 (diff)
downloaddotty-15129574ec21fb66193d183201e5caee7ff53120.tar.gz
dotty-15129574ec21fb66193d183201e5caee7ff53120.tar.bz2
dotty-15129574ec21fb66193d183201e5caee7ff53120.zip
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
Diffstat (limited to 'src/dotty/tools/dotc/transform')
-rw-r--r--src/dotty/tools/dotc/transform/Mixin.scala5
-rw-r--r--src/dotty/tools/dotc/transform/PatternMatcher.scala2
2 files changed, 4 insertions, 3 deletions
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