Skip to content

Commit

Permalink
Only throw TypeErrors for match types with no cases if ctx.isTyper
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneFlesselle committed Mar 17, 2024
1 parent ed5ddfe commit be4065e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3594,8 +3594,14 @@ class MatchReducer(initctx: Context) extends TypeComparer(initctx) {
MatchTypeTrace.emptyScrutinee(scrut)
NoType
case Nil =>
val casesText = MatchTypeTrace.noMatchesText(scrut, cases)
throw MatchTypeReductionError(em"Match type reduction $casesText")
if ctx.isTyper then
val casesText = MatchTypeTrace.noMatchesText(scrut, cases)
throw MatchTypeReductionError(em"Match type reduction $casesText")
else
NoType
/* The match type is left unreduced if an error can not be reported
* See pos/constvalue-of-failed-match-type.scala for an example
*/

inFrozenConstraint(recur(cases))
}
Expand Down

0 comments on commit be4065e

Please sign in to comment.