summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-02-19 15:04:17 +0000
committerPaul Phillips <paulp@improving.org>2009-02-19 15:04:17 +0000
commit972e5c52af5da6921a398a91db9db39da2addd2e (patch)
tree9542dbaf948738849eb95ef939ec5780f081425b /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parentf4411a5ab0d4bfdb4f836296fc3d6900777c1077 (diff)
downloadscala-972e5c52af5da6921a398a91db9db39da2addd2e.tar.gz
scala-972e5c52af5da6921a398a91db9db39da2addd2e.tar.bz2
scala-972e5c52af5da6921a398a91db9db39da2addd2e.zip
Improved error messages for certain illegal ove...
Improved error messages for certain illegal overriding situations, plus test cases. Resolves bug #276.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 745979790b..bcc1a1686e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -208,6 +208,11 @@ abstract class RefChecks extends InfoTransform {
(ob == RootClass || ob == NoSymbol || !ob.hasTransOwner(mb) ||
(other hasFlag PROTECTED) && !(member hasFlag PROTECTED))) {
overrideAccessError()
+ }
+ else if (other.isClass || other.isModule) {
+ overrideError("cannot be used here - classes and objects cannot be overridden");
+ } else if (!other.isDeferred && (member.isClass || member.isModule)) {
+ overrideError("cannot be used here - classes and objects can only override abstract types");
} else if (other hasFlag FINAL) { // (1.2)
overrideError("cannot override final member");
} else if (!other.isDeferred && !(member hasFlag (OVERRIDE | ABSOVERRIDE | SYNTHETIC))) { // (1.3), SYNTHETIC because of DEVIRTUALIZE