Skip to content

Commit 34387c7

Browse files
committed
Improved an error message.
Closes SI-4319, no review.
1 parent 8987550 commit 34387c7

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,9 +1121,9 @@ trait Typers extends Modes with Adaptations {
11211121
if (!phase.erasedTypes) {
11221122
for (ancestor <- clazz.ancestors find (_.isCase)) {
11231123
unit.error(clazz.pos, (
1124-
"case class `%s' has case ancestor `%s'. Case-to-case inheritance is prohibited."+
1125-
" To overcome this limitation use extractors to pattern match on non-leaf nodes."
1126-
).format(clazz, ancestor))
1124+
"case %s has case ancestor %s, but case-to-case inheritance is prohibited."+
1125+
" To overcome this limitation, use extractors to pattern match on non-leaf nodes."
1126+
).format(clazz, ancestor.fullName))
11271127
}
11281128
}
11291129
}

test/files/neg/caseinherit.check

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
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.
2-
case class B(y: Int) extends A(y)
3-
^
4-
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.
5-
case object Bippy extends A(55)
6-
^
7-
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.
8-
case class Dingus(y: Int) extends Innocent
9-
^
1+
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.
2+
case class B(y: Int) extends A(y)
3+
^
4+
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.
5+
case object Bippy extends A(55)
6+
^
7+
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.
8+
case class Dingus(y: Int) extends Innocent
9+
^
1010
three errors found

test/files/neg/caseinherit.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
case class A(x: Int)
2-
case class B(y: Int) extends A(y)
3-
case object Bippy extends A(55)
1+
package foo {
2+
case class A(x: Int)
3+
case class B(y: Int) extends A(y)
4+
case object Bippy extends A(55)
5+
}
6+
import foo._
47

5-
class Innocent extends A(5)
6-
case class Dingus(y: Int) extends Innocent
8+
package bar {
9+
class Blameless(x: Int)
10+
class Innocent extends A(5)
11+
case class Dingus(y: Int) extends Innocent
12+
case object Hungle extends Blameless(5)
13+
}

test/files/neg/t0816.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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.
1+
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.
22
case class Ctest(override val data: String) extends Btest(data, true)
33
^
44
one error found

test/files/neg/t425.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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.
1+
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.
22
case class B(override val x: Int, y: Double) extends A(x)
33
^
44
one error found

0 commit comments

Comments
 (0)