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 {
329
329
330
330
val mixinOverrideErrors = new mutable.ListBuffer [MixinOverrideError ]()
331
331
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
+
332
341
def printMixinOverrideErrors (): Unit =
333
342
mixinOverrideErrors.toList match {
334
343
case Nil =>
@@ -914,7 +923,7 @@ object RefChecks {
914
923
checkNoAbstractDecls(clazz)
915
924
916
925
if (abstractErrors.nonEmpty)
917
- report.error(abstractErrorMessage, clazz.srcPos )
926
+ report.error(abstractErrorMessage, clazzNamePos )
918
927
919
928
checkMemberTypesOK()
920
929
checkCaseClassInheritanceInvariant()
Original file line number Diff line number Diff line change 1
1
-- Error: tests/neg/i10666.scala:8:6 -----------------------------------------------------------------------------------
2
2
8 |class Bar extends Foo { // error
3
- | ^
3
+ | ^^^
4
4
| class Bar needs to be abstract, since def foo[T <: B](tx: T): Unit in trait Foo is not defined
5
5
| (Note that
6
6
| 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 1
1
-- Error: tests/neg/i12828.scala:7:7 -----------------------------------------------------------------------------------
2
2
7 |object Baz extends Bar[Int] // error: not implemented
3
- | ^
3
+ | ^^^
4
4
| object creation impossible, since def foo(x: A): Unit in trait Foo is not defined
5
5
| (Note that
6
6
| parameter A in def foo(x: A): Unit in trait Foo does not match
Original file line number Diff line number Diff line change 1
1
-- Error: tests/neg/i13466.scala:9:6 -----------------------------------------------------------------------------------
2
2
9 |given none: SomeTrait[Finally] with {} // error
3
- | ^
3
+ | ^^^^
4
4
| object creation impossible, since:
5
5
| it has 3 unimplemented members.
6
6
| /** As seen from module class none$, the missing signatures are as follows.
Original file line number Diff line number Diff line change 1
1
-- Error: tests/neg/i19731.scala:4:6 -----------------------------------------------------------------------------------
2
2
4 |class F1 extends Foo: // error
3
- | ^
3
+ | ^^
4
4
| class F1 needs to be abstract, since def foo(): Unit in class F1 is not defined
5
5
-- Error: tests/neg/i19731.scala:7:6 -----------------------------------------------------------------------------------
6
6
7 |class F2 extends Foo: // error
7
- | ^
7
+ | ^^
8
8
| class F2 needs to be abstract, since:
9
9
| it has 2 unimplemented members.
10
10
| /** As seen from class F2, the missing signatures are as follows.
14
14
| def foo(x: Int): Unit = ???
15
15
-- Error: tests/neg/i19731.scala:16:6 ----------------------------------------------------------------------------------
16
16
16 |class B1 extends Bar: // error
17
- | ^
17
+ | ^^
18
18
| class B1 needs to be abstract, since:
19
19
| it has 2 unimplemented members.
20
20
| /** As seen from class B1, the missing signatures are as follows.
Original file line number Diff line number Diff line change 1
1
-- Error: tests/neg/i21335.scala:7:6 -----------------------------------------------------------------------------------
2
2
7 |class Z1 extends Bar1 // error
3
- | ^
3
+ | ^^
4
4
| class Z1 needs to be abstract, since override def bar(): Bar1 in trait Bar1 is not defined
5
5
-- Error: tests/neg/i21335.scala:12:6 ----------------------------------------------------------------------------------
6
6
12 |class Z2 extends Bar2 // error
7
- | ^
7
+ | ^^
8
8
| 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 1
1
-- Error: tests/neg/i9329.scala:8:6 ------------------------------------------------------------------------------------
2
2
8 |class GrandSon extends Son // error
3
- | ^
3
+ | ^^^^^^^^
4
4
|class GrandSon needs to be abstract, since def name: String in trait Parent is not defined
5
5
|(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 15
15
| method ++ of type (xs: Alpha[String]): Alpha[String] misses a target name annotation @targetName(append)
16
16
-- Error: tests/neg/targetName-override.scala:14:6 ---------------------------------------------------------------------
17
17
14 |class Beta extends Alpha[String] { // error: needs to be abstract
18
- | ^
18
+ | ^^^^
19
19
|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