Skip to content

Commit cb2d81d

Browse files
committed
Better error message for RefChecks
Trying to diagnose failure of t2503 and t5577 which were moved to disabled in the time the tests did not work. These failed locally for me, but the checkin tests succeeded (since the checkin tests tested something else). Added better diagnostics to RefChecks which now mention candidate implementations of missing abstract members that have the right name but not the right type.
1 parent 94821af commit cb2d81d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ object RefChecks {
420420
for (member <- missing) {
421421
val memberSym = member.symbol
422422
def undefined(msg: String) =
423-
abstractClassError(false, member.showDcl + " is not defined" + msg)
423+
abstractClassError(false, s"${member.showDcl} is not defined $msg")
424424
val underlying = memberSym.underlyingSymbol
425425

426426
// Give a specific error message for abstract vars based on why it fails:
@@ -456,9 +456,8 @@ object RefChecks {
456456
case (pa, pc) :: Nil =>
457457
val abstractSym = pa.typeSymbol
458458
val concreteSym = pc.typeSymbol
459-
def subclassMsg(c1: Symbol, c2: Symbol) = (
460-
": %s is a subclass of %s, but method parameter types must match exactly.".format(
461-
c1.showLocated, c2.showLocated))
459+
def subclassMsg(c1: Symbol, c2: Symbol) =
460+
s": ${c1.showLocated} is a subclass of ${c2.showLocated}, but method parameter types must match exactly."
462461
val addendum =
463462
if (abstractSym == concreteSym) {
464463
val paArgs = pa.argInfos
@@ -478,12 +477,14 @@ object RefChecks {
478477
subclassMsg(concreteSym, abstractSym)
479478
else ""
480479

481-
undefined("\n(Note that %s does not match %s%s)".format(pa, pc, addendum))
480+
undefined(s"\n(Note that $pa does not match $pc$addendum)")
482481
case xs =>
483-
undefined("")
482+
undefined(s"\n(The class implements a member with a different type: ${concrete.showDcl})")
484483
}
485-
case _ =>
484+
case Nil =>
486485
undefined("")
486+
case concretes =>
487+
undefined(s"\n(The class implements members with different types: ${concretes.map(_.showDcl)}%\n %)")
487488
}
488489
} else undefined("")
489490
}

0 commit comments

Comments
 (0)