Skip to content

Commit

Permalink
Let show behave more robustly for Recheck (#21678)
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.

Fixes #21646
  • Loading branch information
odersky authored Oct 1, 2024
2 parents ac28899 + 0f2613c commit c0974f6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 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

0 comments on commit c0974f6

Please sign in to comment.