summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-08-05 16:48:11 +0000
committerMartin Odersky <odersky@gmail.com>2008-08-05 16:48:11 +0000
commite2be618472daa31f442b61a11a4bd3fe434cddce (patch)
tree1c607318344a9e2f4ce6548a93af3293a6562081
parente50c7947b58e4937e1d5bd8a346be3c44592962c (diff)
downloadscala-e2be618472daa31f442b61a11a4bd3fe434cddce.tar.gz
scala-e2be618472daa31f442b61a11a4bd3fe434cddce.tar.bz2
scala-e2be618472daa31f442b61a11a4bd3fe434cddce.zip
fixed #1163.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala28
-rw-r--r--test/files/neg/t1163.check7
-rw-r--r--test/files/neg/t1163.scala2
-rw-r--r--test/pending/pos/bug1087.scala (renamed from test/files/pos/bug1087.scala)0
4 files changed, 28 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index d60f7ef97e..6c50f40d9b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -100,15 +100,19 @@ abstract class RefChecks extends InfoTransform {
def isFBounded(tsym: Symbol) =
tsym.info.baseTypeSeq exists (_ contains tsym)
- def infoString(sym: Symbol) = {
+ def infoString(sym: Symbol) = infoString0(sym, sym.owner != clazz)
+ def infoStringWithLocation(sym: Symbol) = infoString0(sym, true)
+
+ def infoString0(sym: Symbol, showLocation: Boolean) = {
val sym1 = analyzer.underlying(sym)
sym1.toString() +
- (if (sym1.owner == clazz) ""
- else (sym1.locationString +
- (if (sym1.isAliasType) ", which equals "+self.memberInfo(sym1)
- else if (sym1.isAbstractType) " with bounds "+self.memberInfo(sym1)
- else if (sym1.isTerm) " of type "+self.memberInfo(sym1)
- else "")))
+ (if (showLocation)
+ sym1.locationString +
+ (if (sym1.isAliasType) ", which equals "+self.memberInfo(sym1)
+ else if (sym1.isAbstractType) " with bounds "+self.memberInfo(sym1)
+ else if (sym1.isTerm) " of type "+self.memberInfo(sym1)
+ else "")
+ else "")
}
def overridesType(tp1: Type, tp2: Type): Boolean = (tp1.normalize, tp2.normalize) match {
@@ -130,8 +134,14 @@ abstract class RefChecks extends InfoTransform {
def overrideError(msg: String) {
if (other.tpe != ErrorType && member.tpe != ErrorType)
- unit.error(pos, "error overriding " + infoString(other) +
- ";\n " + infoString(member) + " " + msg);
+ unit.error(pos, "error overriding " + infoStringWithLocation(other) +
+ ";\n " + infoString(member) + " " + msg +
+ (if ((other.owner isSubClass member.owner) &&
+ other.isDeferred && !member.isDeferred)
+ ";\n (Note that "+infoStringWithLocation(other)+" is abstract,"+
+ "\n and is therefore overridden by concrete "+
+ infoStringWithLocation(member)+")"
+ else ""))
}
def overrideTypeError() {
diff --git a/test/files/neg/t1163.check b/test/files/neg/t1163.check
new file mode 100644
index 0000000000..c96ec732a5
--- /dev/null
+++ b/test/files/neg/t1163.check
@@ -0,0 +1,7 @@
+t1163.scala:2: error: error overriding method foo in trait Sub of type => Sub;
+ method foo in trait Super of type => Super has incompatible type => Super;
+ (Note that method foo in trait Sub of type => Sub is abstract,
+ and is therefore overridden by concrete method foo in trait Super of type => Super)
+trait Sub extends Super { override def foo: Sub }
+ ^
+one error found
diff --git a/test/files/neg/t1163.scala b/test/files/neg/t1163.scala
new file mode 100644
index 0000000000..caf5747f9e
--- /dev/null
+++ b/test/files/neg/t1163.scala
@@ -0,0 +1,2 @@
+trait Super { def foo: Super = new Super {} }
+trait Sub extends Super { override def foo: Sub }
diff --git a/test/files/pos/bug1087.scala b/test/pending/pos/bug1087.scala
index 19d62116c6..19d62116c6 100644
--- a/test/files/pos/bug1087.scala
+++ b/test/pending/pos/bug1087.scala