aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-01-31 16:37:10 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-09 09:43:06 +0100
commit5fd2028931874291b3cf1b7efef4fed7119d9316 (patch)
treef0c60babe5ff6bc259bb902511cb60e5faaa7544 /src/dotty/tools/dotc
parent9a6f82b2ecfd7462d0a1f4e0464878fd58231277 (diff)
downloaddotty-5fd2028931874291b3cf1b7efef4fed7119d9316.tar.gz
dotty-5fd2028931874291b3cf1b7efef4fed7119d9316.tar.bz2
dotty-5fd2028931874291b3cf1b7efef4fed7119d9316.zip
Enforce rule that laziness is preserved when overriding.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala2
-rw-r--r--src/dotty/tools/dotc/typer/RefChecks.scala12
2 files changed, 8 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index 9ccb03b89..c1132ce4b 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -493,7 +493,7 @@ object Contexts {
}
@sharable object NoContext extends Context {
- lazy val base = unsupported("base")
+ val base = null
override val implicits: ContextualImplicits = new ContextualImplicits(Nil, null)(this)
}
diff --git a/src/dotty/tools/dotc/typer/RefChecks.scala b/src/dotty/tools/dotc/typer/RefChecks.scala
index 7ccb3d103..067694bfd 100644
--- a/src/dotty/tools/dotc/typer/RefChecks.scala
+++ b/src/dotty/tools/dotc/typer/RefChecks.scala
@@ -211,7 +211,7 @@ object RefChecks {
if (!(hasErrors && member.is(Synthetic) && member.is(Module))) {
// suppress errors relating toi synthetic companion objects if other override
// errors (e.g. relating to the companion class) have already been reported.
- if (member.owner == clazz) ctx.error(fullmsg+", member = $member", member.pos)
+ if (member.owner == clazz) ctx.error(fullmsg, member.pos)
else mixinOverrideErrors += new MixinOverrideError(member, fullmsg)
hasErrors = true
}
@@ -330,10 +330,12 @@ object RefChecks {
"(this rule is designed to prevent ``accidental overrides'')")
} else if (other.isStable && !member.isStable) { // (1.4)
overrideError("needs to be a stable, immutable value")
- } else if (member.is(Lazy) && !other.isRealMethod && !other.is(Deferred | Lazy)) {
- overrideError("cannot override a concrete non-lazy value")
- } else if (other.is(Lazy, butNot = Deferred) && !other.isRealMethod && !member.is(Lazy)) {
- overrideError("must be declared lazy to override a concrete lazy value")
+ } else if (member.is(ModuleVal) && !other.isRealMethod && !other.is(Deferred | Lazy)) {
+ overrideError("may not override a concrete non-lazy value")
+ } else if (member.is(Lazy, butNot = Module) && !other.isRealMethod && !other.is(Lazy)) {
+ overrideError("may not override a non-lazy value")
+ } else if (other.is(Lazy) && !other.isRealMethod && !member.is(Lazy)) {
+ overrideError("must be declared lazy to override a lazy value")
} else if (other.is(Deferred) && member.is(Macro) && member.extendedOverriddenSymbols.forall(_.is(Deferred))) { // (1.9)
overrideError("cannot be used here - term macros cannot override abstract methods")
} else if (other.is(Macro) && !member.is(Macro)) { // (1.10)