Skip to content

Commit 0f2613c

Browse files
committed
Localize TypeError handling in addRecheckedTypes
1 parent a990978 commit 0f2613c

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

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

+8-11
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ object Recheck:
3333

3434
val addRecheckedTypes = new TreeMap:
3535
override def transform(tree: Tree)(using Context): Tree =
36-
val tree1 = super.transform(tree)
37-
tree.getAttachment(RecheckedType) match
38-
case Some(tpe) => tree1.withType(tpe)
39-
case None => tree1
36+
try
37+
val tree1 = super.transform(tree)
38+
tree.getAttachment(RecheckedType) match
39+
case Some(tpe) => tree1.withType(tpe)
40+
case None => tree1
41+
catch
42+
case _:TypeError => tree
4043

4144
extension (sym: Symbol)(using Context)
4245

@@ -618,13 +621,7 @@ abstract class Recheck extends Phase, SymTransformer:
618621
override def show(tree: untpd.Tree)(using Context): String =
619622
atPhase(thisPhase):
620623
withMode(Mode.Printing):
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)
624+
super.show(addRecheckedTypes.transform(tree.asInstanceOf[tpd.Tree]))
628625
end Recheck
629626

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

0 commit comments

Comments
 (0)