diff options
author | Martin Odersky <odersky@gmail.com> | 2011-04-08 16:31:26 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-04-08 16:31:26 +0000 |
commit | 26c3f65241f49d96e2b3e853f71aa780ca8861c1 (patch) | |
tree | 8cc94c67ca1a884ace6333e00d8cb8c44e9dcdef /src | |
parent | b13ef720c09f1a7b6e3263faebcb0be7785a5337 (diff) | |
download | scala-26c3f65241f49d96e2b3e853f71aa780ca8861c1.tar.gz scala-26c3f65241f49d96e2b3e853f71aa780ca8861c1.tar.bz2 scala-26c3f65241f49d96e2b3e853f71aa780ca8861c1.zip |
Closes #4431. Review by extempore.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 7 |
1 files changed, 7 insertions, 0 deletions
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` |