summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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