summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-09-28 23:08:28 +0000
committerPaul Phillips <paulp@improving.org>2011-09-28 23:08:28 +0000
commit34387c718492c26072b3cf402eb15494e5a552db (patch)
tree91aff98b123c6dc5f82d97e7d12c61ad6516f395
parent898755056642cc3771d33260295f1f51cabc6513 (diff)
downloadscala-34387c718492c26072b3cf402eb15494e5a552db.tar.gz
scala-34387c718492c26072b3cf402eb15494e5a552db.tar.bz2
scala-34387c718492c26072b3cf402eb15494e5a552db.zip
Improved an error message.
Closes SI-4319, no review.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala6
-rw-r--r--test/files/neg/caseinherit.check18
-rw-r--r--test/files/neg/caseinherit.scala17
-rw-r--r--test/files/neg/t0816.check2
-rw-r--r--test/files/neg/t425.check2
5 files changed, 26 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 1c8b2486c9..5bd936bfb7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1121,9 +1121,9 @@ trait Typers extends Modes with Adaptations {
if (!phase.erasedTypes) {
for (ancestor <- clazz.ancestors find (_.isCase)) {
unit.error(clazz.pos, (
- "case class `%s' has case ancestor `%s'. Case-to-case inheritance is prohibited."+
- " To overcome this limitation use extractors to pattern match on non-leaf nodes."
- ).format(clazz, ancestor))
+ "case %s has case ancestor %s, but case-to-case inheritance is prohibited."+
+ " To overcome this limitation, use extractors to pattern match on non-leaf nodes."
+ ).format(clazz, ancestor.fullName))
}
}
}
diff --git a/test/files/neg/caseinherit.check b/test/files/neg/caseinherit.check
index c185c82f70..09327a4ffa 100644
--- a/test/files/neg/caseinherit.check
+++ b/test/files/neg/caseinherit.check
@@ -1,10 +1,10 @@
-caseinherit.scala:2: error: case class `class B' has case ancestor `class A'. Case-to-case inheritance is prohibited. To overcome this limitation use extractors to pattern match on non-leaf nodes.
-case class B(y: Int) extends A(y)
- ^
-caseinherit.scala:3: error: case class `object Bippy' has case ancestor `class A'. Case-to-case inheritance is prohibited. To overcome this limitation use extractors to pattern match on non-leaf nodes.
-case object Bippy extends A(55)
- ^
-caseinherit.scala:6: error: case class `class Dingus' has case ancestor `class A'. Case-to-case inheritance is prohibited. To overcome this limitation use extractors to pattern match on non-leaf nodes.
-case class Dingus(y: Int) extends Innocent
- ^
+caseinherit.scala:3: error: case class B has case ancestor foo.A, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.
+ case class B(y: Int) extends A(y)
+ ^
+caseinherit.scala:4: error: case object Bippy has case ancestor foo.A, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.
+ case object Bippy extends A(55)
+ ^
+caseinherit.scala:11: error: case class Dingus has case ancestor foo.A, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.
+ case class Dingus(y: Int) extends Innocent
+ ^
three errors found
diff --git a/test/files/neg/caseinherit.scala b/test/files/neg/caseinherit.scala
index fdac97c98e..5c8da13d31 100644
--- a/test/files/neg/caseinherit.scala
+++ b/test/files/neg/caseinherit.scala
@@ -1,6 +1,13 @@
-case class A(x: Int)
-case class B(y: Int) extends A(y)
-case object Bippy extends A(55)
+package foo {
+ case class A(x: Int)
+ case class B(y: Int) extends A(y)
+ case object Bippy extends A(55)
+}
+import foo._
-class Innocent extends A(5)
-case class Dingus(y: Int) extends Innocent \ No newline at end of file
+package bar {
+ class Blameless(x: Int)
+ class Innocent extends A(5)
+ case class Dingus(y: Int) extends Innocent
+ case object Hungle extends Blameless(5)
+} \ No newline at end of file
diff --git a/test/files/neg/t0816.check b/test/files/neg/t0816.check
index ff6489be99..48f37c1414 100644
--- a/test/files/neg/t0816.check
+++ b/test/files/neg/t0816.check
@@ -1,4 +1,4 @@
-t0816.scala:5: error: case class `class Ctest' has case ancestor `class Btest'. Case-to-case inheritance is prohibited. To overcome this limitation use extractors to pattern match on non-leaf nodes.
+t0816.scala:5: error: case class Ctest has case ancestor Btest, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.
case class Ctest(override val data: String) extends Btest(data, true)
^
one error found
diff --git a/test/files/neg/t425.check b/test/files/neg/t425.check
index 671c128753..77ea0c5a4b 100644
--- a/test/files/neg/t425.check
+++ b/test/files/neg/t425.check
@@ -1,4 +1,4 @@
-t425.scala:3: error: case class `class B' has case ancestor `class A'. Case-to-case inheritance is prohibited. To overcome this limitation use extractors to pattern match on non-leaf nodes.
+t425.scala:3: error: case class B has case ancestor Temp.A, but case-to-case inheritance is prohibited. To overcome this limitation, use extractors to pattern match on non-leaf nodes.
case class B(override val x: Int, y: Double) extends A(x)
^
one error found