Skip to content

Commit a990978

Browse files
committed
Let show behave more robustly for Recheck
The pretty-printing logic for a Recheck phase applies the phase to the tree. But if there was a type error, then the pretty printing would have previously crashed the compiler.
1 parent 9961e70 commit a990978

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/transform/Recheck.scala

+7-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,13 @@ abstract class Recheck extends Phase, SymTransformer:
618618
override def show(tree: untpd.Tree)(using Context): String =
619619
atPhase(thisPhase):
620620
withMode(Mode.Printing):
621-
super.show(addRecheckedTypes.transform(tree.asInstanceOf[tpd.Tree]))
621+
val ttree0 = tree.asInstanceOf[tpd.Tree]
622+
val ttree1 =
623+
try
624+
addRecheckedTypes.transform(ttree0)
625+
catch
626+
case _:TypeError => ttree0
627+
super.show(ttree1)
622628
end Recheck
623629

624630
/** A class that can be used to test basic rechecking without any customaization */

0 commit comments

Comments
 (0)