From a99097804bef56c3d84efd0b61f0f602a33f9605 Mon Sep 17 00:00:00 2001 From: Oliver Bracevac Date: Mon, 30 Sep 2024 20:05:28 +0200 Subject: [PATCH] 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. --- compiler/src/dotty/tools/dotc/transform/Recheck.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/transform/Recheck.scala b/compiler/src/dotty/tools/dotc/transform/Recheck.scala index 03f0001110d3..ecf5c69d1f91 100644 --- a/compiler/src/dotty/tools/dotc/transform/Recheck.scala +++ b/compiler/src/dotty/tools/dotc/transform/Recheck.scala @@ -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 */