summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-11-09 11:38:42 +0000
committerMartin Odersky <odersky@gmail.com>2009-11-09 11:38:42 +0000
commitfe8ed5a8f992ae1a11620cb954e1b4a543327496 (patch)
tree42118999d66851503d3e4966ddb86975bcb452bb /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parent47ff60552398b09a8b757345cd56f12091d97b92 (diff)
downloadscala-fe8ed5a8f992ae1a11620cb954e1b4a543327496.tar.gz
scala-fe8ed5a8f992ae1a11620cb954e1b4a543327496.tar.bz2
scala-fe8ed5a8f992ae1a11620cb954e1b4a543327496.zip
Fixed #2569
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 31ebdc5906..0b285da72d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -448,11 +448,20 @@ abstract class RefChecks extends InfoTransform {
if (!(clazz hasFlag ABSTRACT)) checkNoAbstractDecls(clazz)
}
+ /** Does there exists a symbol declared in class `inclazz` with name `name` and
+ * whose type seen as a member of `class.thisType` matches `tpe`?
+ */
+ def hasMatchingSym(inclazz: Symbol, name: Name, tpe: Type): Boolean =
+ inclazz.info.nonPrivateDecl(name).filter(sym =>
+ !sym.isTerm || (tpe matches clazz.thisType.memberType(sym))) != NoSymbol
+
// 4. Check that every defined member with an `override' modifier overrides some other member.
for (member <- clazz.info.decls.toList)
if ((member hasFlag (OVERRIDE | ABSOVERRIDE)) &&
- (clazz.ancestors forall {
- bc => member.matchingSymbol(bc, clazz.thisType) == NoSymbol
+ !(clazz.ancestors exists { bc =>
+ hasMatchingSym(bc, member.name, member.tpe) ||
+ hasRepeatedParam(member.tpe) &&
+ hasMatchingSym(bc, member.name, toJavaRepeatedParam(member.tpe))
})) {
// for (bc <- clazz.info.baseClasses.tail) Console.println("" + bc + " has " + bc.info.decl(member.name) + ":" + bc.info.decl(member.name).tpe);//DEBUG
unit.error(member.pos, member.toString() + " overrides nothing");