Skip to content

Commit

Permalink
Let show behave more robustly for Recheck
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bracevac committed Sep 30, 2024
1 parent 9961e70 commit a990978
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Recheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,13 @@ abstract class Recheck extends Phase, SymTransformer:
override def show(tree: untpd.Tree)(using Context): String =
atPhase(thisPhase):
withMode(Mode.Printing):
super.show(addRecheckedTypes.transform(tree.asInstanceOf[tpd.Tree]))
val ttree0 = tree.asInstanceOf[tpd.Tree]
val ttree1 =
try
addRecheckedTypes.transform(ttree0)
catch
case _:TypeError => ttree0
super.show(ttree1)
end Recheck

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

0 comments on commit a990978

Please sign in to comment.