summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index fbe01c7fac..c4a3981a51 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -453,21 +453,25 @@ 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`?
+ /** Returns whether there is a symbol declared in class `inclazz`
+ * (which must be different from `clazz`) whose name and type
+ * seen as a member of `class.thisType` matches `member`'s.
*/
- def hasMatchingSym(inclazz: Symbol, name: Name, tpe: Type): Boolean =
- inclazz.info.nonPrivateDecl(name).filter(sym =>
- !sym.isTerm || (tpe matches clazz.thisType.memberType(sym))) != NoSymbol
+ def hasMatchingSym(inclazz: Symbol, member: Symbol): Boolean =
+ inclazz != clazz && {
+ val isVarargs = hasRepeatedParam(member.tpe)
+ inclazz.info.nonPrivateDecl(member.name).filter { sym =>
+ !sym.isTerm || {
+ val symtpe = clazz.thisType.memberType(sym)
+ (member.tpe matches symtpe) || isVarargs && (toJavaRepeatedParam(member.tpe) matches symtpe)
+ }
+ } != 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 exists { bc =>
- hasMatchingSym(bc, member.name, member.tpe) ||
- hasRepeatedParam(member.tpe) &&
- hasMatchingSym(bc, member.name, toJavaRepeatedParam(member.tpe))
- })) {
+ !(clazz.thisType.baseClasses exists (hasMatchingSym(_, member)))) {
// 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");
member resetFlag OVERRIDE