diff options
author | Paul Phillips <paulp@improving.org> | 2012-02-19 19:40:08 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-02-19 20:15:11 -0800 |
commit | a6a9684f5ba5df146be1f24bd170e97f0b2208ce (patch) | |
tree | b6c610fb4173e0561a2df7487f23fb17b715e2c3 /src | |
parent | e512518d25818b4b0381e4a078137734f8eab12f (diff) | |
download | scala-a6a9684f5ba5df146be1f24bd170e97f0b2208ce.tar.gz scala-a6a9684f5ba5df146be1f24bd170e97f0b2208ce.tar.bz2 scala-a6a9684f5ba5df146be1f24bd170e97f0b2208ce.zip |
A better error message for inheritance conflict.
And some tests for pending.
Closes SI-5358.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index e313edb3f6..35db38ae77 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -282,6 +282,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R def otherTp = self.memberType(other) def noErrorType = other.tpe != ErrorType && member.tpe != ErrorType def isRootOrNone(sym: Symbol) = sym == RootClass || sym == NoSymbol + def isNeitherInClass = (member.owner != clazz) && (other.owner != clazz) def objectOverrideErrorMsg = ( "overriding " + other.fullLocationString + " with " + member.fullLocationString + ":\n" + "an overriding object must conform to the overridden object's class bound" + @@ -383,7 +384,14 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R overrideError("cannot override final member"); // synthetic exclusion needed for (at least) default getters. } else if (!other.isDeferred && !member.isAnyOverride && !member.isSynthetic) { - overrideError("needs `override' modifier"); + if (isNeitherInClass && !(other.owner isSubClass member.owner)) + emitOverrideError( + clazz + " inherits conflicting members:\n " + + infoStringWithLocation(other) + " and\n " + infoStringWithLocation(member) + + "\n(Note: this can be resolved by declaring an override in " + clazz + ".)" + ) + else + overrideError("needs `override' modifier") } else if (other.isAbstractOverride && other.isIncompleteIn(clazz) && !member.isAbstractOverride) { overrideError("needs `abstract override' modifiers") } else if (member.isAnyOverride && (other hasFlag ACCESSOR) && other.accessed.isVariable && !other.accessed.isLazy) { |