Skip to content

Commit

Permalink
Localize TypeError handling in addRecheckedTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
bracevac committed Oct 1, 2024
1 parent a990978 commit 0f2613c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions compiler/src/dotty/tools/dotc/transform/Recheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,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)(using Context)

Expand Down Expand Up @@ -618,13 +621,7 @@ abstract class Recheck extends Phase, SymTransformer:
override def show(tree: untpd.Tree)(using Context): String =
atPhase(thisPhase):
withMode(Mode.Printing):
val ttree0 = tree.asInstanceOf[tpd.Tree]
val ttree1 =
try
addRecheckedTypes.transform(ttree0)
catch
case _:TypeError => ttree0
super.show(ttree1)
super.show(addRecheckedTypes.transform(tree.asInstanceOf[tpd.Tree]))
end Recheck

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

0 comments on commit 0f2613c

Please sign in to comment.