From 26c3f65241f49d96e2b3e853f71aa780ca8861c1 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 8 Apr 2011 16:31:26 +0000 Subject: Closes #4431. Review by extempore. --- src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 18413de51f..3eb5107870 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -550,6 +550,13 @@ abstract class RefChecks extends InfoTransform { if (abstractErrors.nonEmpty) unit.error(clazz.pos, abstractErrorMessage) + } else if (clazz.isTrait) { + // prevent abstract methods in interfaces that override final members in Object; see #4431 + for (decl <- clazz.info.decls.iterator) { + val overridden = decl.overriddenSymbol(ObjectClass) + if (overridden.isFinal) + unit.error(decl.pos, "trait cannot redefine final method from class AnyRef") + } } /** Returns whether there is a symbol declared in class `inclazz` -- cgit v1.2.3