summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-04-07 14:30:56 +0000
committerMartin Odersky <odersky@gmail.com>2011-04-07 14:30:56 +0000
commit42dbce32957e048173c1749697d6bf9273581030 (patch)
tree123bfc813995c1efb19711871ffa6cc494db0e50 /src/compiler/scala/tools/nsc
parent21f3cf0e80286a12c267b9e68c8df8a37f4e0c04 (diff)
downloadscala-42dbce32957e048173c1749697d6bf9273581030.tar.gz
scala-42dbce32957e048173c1749697d6bf9273581030.tar.bz2
scala-42dbce32957e048173c1749697d6bf9273581030.zip
Fixes #2808 without redefining what override me...
Fixes #2808 without redefining what override means. Review by extempore.
Diffstat (limited to 'src/compiler/scala/tools/nsc')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index c558610535..d17077b129 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -1401,8 +1401,17 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
final def overridingSymbol(ofclazz: Symbol): Symbol =
if (isClassConstructor) NoSymbol else matchingSymbol(ofclazz, ofclazz.thisType)
+ /** Returns all symbols overriden by this symbol
+ */
final def allOverriddenSymbols: List[Symbol] =
if (!owner.isClass) Nil
+ else owner.ancestors map overriddenSymbol filter (_ != NoSymbol)
+
+ /** Returns all symbols overridden by this symbol, plus all matching symbols
+ * defined in parents of the selftype
+ */
+ final def extendedOverriddenSymbols: List[Symbol] =
+ if (!owner.isClass) Nil
else owner.thisSym.ancestors map overriddenSymbol filter (_ != NoSymbol)
/** The symbol accessed by a super in the definition of this symbol when
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 63542e6dd5..18413de51f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -352,7 +352,7 @@ abstract class RefChecks extends InfoTransform {
} else if ((member hasFlag (OVERRIDE | ABSOVERRIDE)) &&
!(member.owner.thisType.baseClasses exists (_ isSubClass other.owner)) &&
!member.isDeferred && !other.isDeferred &&
- intersectionIsEmpty(member.allOverriddenSymbols, other.allOverriddenSymbols)) {
+ intersectionIsEmpty(member.extendedOverriddenSymbols, other.extendedOverriddenSymbols)) {
overrideError("cannot override a concrete member without a third member that's overridden by both "+
"(this rule is designed to prevent ``accidental overrides'')")
} else if (other.isStable && !member.isStable) { // (1.4)