File tree Expand file tree Collapse file tree 10 files changed +29
-11
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 10 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,15 @@ object RefChecks {
329329
330330 val mixinOverrideErrors = new mutable.ListBuffer [MixinOverrideError ]()
331331
332+ /** Returns a `SourcePosition` containing the full span (with the correct
333+ * end) of the class name. */
334+ def clazzNamePos =
335+ if clazz.name == tpnme.ANON_CLASS then
336+ clazz.srcPos
337+ else
338+ val clazzNameEnd = clazz.srcPos.span.start + clazz.name.stripModuleClassSuffix.lastPart.length
339+ clazz.srcPos.sourcePos.copy(span = clazz.srcPos.span.withEnd(clazzNameEnd))
340+
332341 def printMixinOverrideErrors (): Unit =
333342 mixinOverrideErrors.toList match {
334343 case Nil =>
@@ -914,7 +923,7 @@ object RefChecks {
914923 checkNoAbstractDecls(clazz)
915924
916925 if (abstractErrors.nonEmpty)
917- report.error(abstractErrorMessage, clazz.srcPos )
926+ report.error(abstractErrorMessage, clazzNamePos )
918927
919928 checkMemberTypesOK()
920929 checkCaseClassInheritanceInvariant()
Original file line number Diff line number Diff line change 11-- Error: tests/neg/i10666.scala:8:6 -----------------------------------------------------------------------------------
228 |class Bar extends Foo { // error
3- | ^
3+ | ^^^
44 | class Bar needs to be abstract, since def foo[T <: B](tx: T): Unit in trait Foo is not defined
55 | (Note that
66 | parameter T in def foo[T <: B](tx: T): Unit in trait Foo does not match
Original file line number Diff line number Diff line change 11-- Error: tests/neg/i12828.scala:7:7 -----------------------------------------------------------------------------------
227 |object Baz extends Bar[Int] // error: not implemented
3- | ^
3+ | ^^^
44 | object creation impossible, since def foo(x: A): Unit in trait Foo is not defined
55 | (Note that
66 | parameter A in def foo(x: A): Unit in trait Foo does not match
Original file line number Diff line number Diff line change 11-- Error: tests/neg/i13466.scala:9:6 -----------------------------------------------------------------------------------
229 |given none: SomeTrait[Finally] with {} // error
3- | ^
3+ | ^^^^
44 | object creation impossible, since:
55 | it has 3 unimplemented members.
66 | /** As seen from module class none$, the missing signatures are as follows.
Original file line number Diff line number Diff line change 11-- Error: tests/neg/i19731.scala:4:6 -----------------------------------------------------------------------------------
224 |class F1 extends Foo: // error
3- | ^
3+ | ^^
44 | class F1 needs to be abstract, since def foo(): Unit in class F1 is not defined
55-- Error: tests/neg/i19731.scala:7:6 -----------------------------------------------------------------------------------
667 |class F2 extends Foo: // error
7- | ^
7+ | ^^
88 | class F2 needs to be abstract, since:
99 | it has 2 unimplemented members.
1010 | /** As seen from class F2, the missing signatures are as follows.
1414 | def foo(x: Int): Unit = ???
1515-- Error: tests/neg/i19731.scala:16:6 ----------------------------------------------------------------------------------
161616 |class B1 extends Bar: // error
17- | ^
17+ | ^^
1818 | class B1 needs to be abstract, since:
1919 | it has 2 unimplemented members.
2020 | /** As seen from class B1, the missing signatures are as follows.
Original file line number Diff line number Diff line change 11-- Error: tests/neg/i21335.scala:7:6 -----------------------------------------------------------------------------------
227 |class Z1 extends Bar1 // error
3- | ^
3+ | ^^
44 | class Z1 needs to be abstract, since override def bar(): Bar1 in trait Bar1 is not defined
55-- Error: tests/neg/i21335.scala:12:6 ----------------------------------------------------------------------------------
6612 |class Z2 extends Bar2 // error
7- | ^
7+ | ^^
88 | class Z2 needs to be abstract, since def bar(): Bar2 in trait Bar2 is not defined
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg/i22941.scala:4:6 -----------------------------------------------------------------------------------
2+ 4 |class Baz extends Foo: // error
3+ | ^^^
4+ | class Baz needs to be abstract, since def bar: String in trait Foo is not defined
Original file line number Diff line number Diff line change 1+ trait Foo :
2+ def bar : String
3+
4+ class Baz extends Foo : // error
5+ val a = " hello"
Original file line number Diff line number Diff line change 11-- Error: tests/neg/i9329.scala:8:6 ------------------------------------------------------------------------------------
228 |class GrandSon extends Son // error
3- | ^
3+ | ^^^^^^^^
44 |class GrandSon needs to be abstract, since def name: String in trait Parent is not defined
55 |(The class implements abstract override def name: String in trait Son but that definition still needs an implementation)
Original file line number Diff line number Diff line change 1515 | method ++ of type (xs: Alpha[String]): Alpha[String] misses a target name annotation @targetName(append)
1616-- Error: tests/neg/targetName-override.scala:14:6 ---------------------------------------------------------------------
171714 |class Beta extends Alpha[String] { // error: needs to be abstract
18- | ^
18+ | ^^^^
1919 |class Beta needs to be abstract, since there is a deferred declaration of method foo in class Alpha of type (x: String): String which is not implemented in a subclass
You can’t perform that action at this time.
0 commit comments