File tree 3 files changed +49
-4
lines changed
compiler/src/dotty/tools/dotc/typer 3 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -654,8 +654,9 @@ object RefChecks {
654
654
655
655
val missingMethods = grouped.toList flatMap {
656
656
case (name, syms) =>
657
- val withoutSetters = syms filterNot (_.isSetter)
658
- if (withoutSetters.nonEmpty) withoutSetters else syms
657
+ syms.filterConserve(! _.isSetter)
658
+ .groupBy(_.signature) // Avoid duplication for similar definitions (#19731)
659
+ .map(f => f._2.head) // _1: Closest undefined method to the scope
659
660
}
660
661
661
662
def stubImplementations : List [String ] = {
@@ -666,7 +667,7 @@ object RefChecks {
666
667
667
668
if (regrouped.tail.isEmpty)
668
669
membersStrings(regrouped.head._2)
669
- else (regrouped.sortBy(" " + _._1.name) flatMap {
670
+ else (regrouped.sortBy(_._1.name.toString() ) flatMap {
670
671
case (owner, members) =>
671
672
(" // Members declared in " + owner.fullName) +: membersStrings(members) :+ " "
672
673
}).init
@@ -685,7 +686,7 @@ object RefChecks {
685
686
return
686
687
}
687
688
688
- for (member <- missing ) {
689
+ for (member <- missingMethods ) {
689
690
def showDclAndLocation (sym : Symbol ) =
690
691
s " ${sym.showDcl} in ${sym.owner.showLocated}"
691
692
def undefined (msg : String ) =
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg/i19731.scala:4:6 -----------------------------------------------------------------------------------
2
+ 4 |class F1 extends Foo: // error
3
+ | ^
4
+ | class F1 needs to be abstract, since def foo(): Unit in class F1 is not defined
5
+ -- Error: tests/neg/i19731.scala:7:6 -----------------------------------------------------------------------------------
6
+ 7 |class F2 extends Foo: // error
7
+ | ^
8
+ | class F2 needs to be abstract, since:
9
+ | it has 2 unimplemented members.
10
+ | /** As seen from class F2, the missing signatures are as follows.
11
+ | * For convenience, these are usable as stub implementations.
12
+ | */
13
+ | def foo(x: Int): Unit = ???
14
+ | def foo(): Unit = ???
15
+ -- Error: tests/neg/i19731.scala:16:6 ----------------------------------------------------------------------------------
16
+ 16 |class B1 extends Bar: // error
17
+ | ^
18
+ | class B1 needs to be abstract, since:
19
+ | it has 2 unimplemented members.
20
+ | /** As seen from class B1, the missing signatures are as follows.
21
+ | * For convenience, these are usable as stub implementations.
22
+ | */
23
+ | // Members declared in B1
24
+ | def foo(x: Int): Unit = ???
25
+ |
26
+ | // Members declared in Bar
27
+ | def foo(): Unit = ???
Original file line number Diff line number Diff line change
1
+ trait Foo :
2
+ def foo (): Unit
3
+
4
+ class F1 extends Foo : // error
5
+ def foo (): Unit
6
+
7
+ class F2 extends Foo : // error
8
+ def foo (): Unit
9
+ def foo (x : Int ): Unit
10
+
11
+
12
+ trait Bar :
13
+ def foo (): Unit
14
+ def foo (x : Int ): Unit
15
+
16
+ class B1 extends Bar : // error
17
+ def foo (x : Int ): Unit
You can’t perform that action at this time.
0 commit comments