Skip to content

Commit b579fc5

Browse files
committed
Report the first cyclic error
Sometimes, printing a cyclic error leads to another cyclic error. In this case we should print the original error, not the error caused by the printing.
1 parent ef9d827 commit b579fc5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2238,7 +2238,11 @@ object messages {
22382238

22392239
class IllegalCyclicTypeReference(sym: Symbol, where: String, lastChecked: Type)(using ctx: Context)
22402240
extends CyclicMsg(IllegalCyclicTypeReferenceID) {
2241-
def msg = i"illegal cyclic type reference: ${where} ${hl(lastChecked.show)} of $sym refers back to the type itself"
2241+
def msg =
2242+
val lastCheckedStr =
2243+
try lastChecked.show
2244+
catch case ex: CyclicReference => "..."
2245+
i"illegal cyclic type reference: ${where} ${hl(lastCheckedStr)} of $sym refers back to the type itself"
22422246
def explain = ""
22432247
}
22442248

0 commit comments

Comments
 (0)