From e8e3eabf777424edc6a6020dd6c5505342f6db7a Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Thu, 5 Dec 2024 16:07:22 +0100 Subject: [PATCH 1/2] 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. [Cherry-picked a99097804bef56c3d84efd0b61f0f602a33f9605][modified] From 15e4ee08a59979b570297150b64a5d462f6cc855 Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Thu, 5 Dec 2024 16:07:52 +0100 Subject: [PATCH 2/2] Localize TypeError handling in addRecheckedTypes [Cherry-picked 0f2613c7aec3c222e191ca86301db1fb8127a716][modified] --- compiler/src/dotty/tools/dotc/transform/Recheck.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/Recheck.scala b/compiler/src/dotty/tools/dotc/transform/Recheck.scala index 5963a98f50f2..2eebc2347eec 100644 --- a/compiler/src/dotty/tools/dotc/transform/Recheck.scala +++ b/compiler/src/dotty/tools/dotc/transform/Recheck.scala @@ -39,10 +39,13 @@ object Recheck: val addRecheckedTypes = new TreeMap: override def transform(tree: Tree)(using Context): Tree = - val tree1 = super.transform(tree) - tree.getAttachment(RecheckedType) match - case Some(tpe) => tree1.withType(tpe) - case None => tree1 + try + val tree1 = super.transform(tree) + tree.getAttachment(RecheckedType) match + case Some(tpe) => tree1.withType(tpe) + case None => tree1 + catch + case _:TypeError => tree extension (sym: Symbol)