Skip to content

Commit cca4732

Browse files
griggtSethTisue
andcommitted
Generate suggested stub methods as seen from implementing class
Fixes #13076 Co-authored-by: Seth Tisue <[email protected]>
1 parent fa40f4e commit cca4732

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ object RefChecks {
589589
// Grouping missing methods by the declaring class
590590
val regrouped = missingMethods.groupBy(_.owner).toList
591591
def membersStrings(members: List[Symbol]) =
592-
members.sortBy(_.name.toString).map(_.showDcl + " = ???")
592+
members.sortBy(_.name.toString).map(_.asSeenFrom(clazz.thisType).showDcl + " = ???")
593593

594594
if (regrouped.tail.isEmpty)
595595
membersStrings(regrouped.head._2)

tests/neg/i13076.check

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Error: tests/neg/i13076.scala:6:6 -----------------------------------------------------------------------------------
2+
6 |class C[X, Y] extends T[X, Y] {} // error
3+
| ^
4+
| class C needs to be abstract, since:
5+
| it has 2 unimplemented members.
6+
| /** As seen from class C, the missing signatures are as follows.
7+
| * For convenience, these are usable as stub implementations.
8+
| */
9+
| def f(a: X): Y = ???
10+
| def g(a: X, b: Y): Unit = ???

tests/neg/i13076.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait T[A, B] {
2+
def f(a: A): B
3+
def g(a: A, b: B): Unit
4+
}
5+
6+
class C[X, Y] extends T[X, Y] {} // error

0 commit comments

Comments
 (0)