Skip to content

Commit be4065e

Browse files
Only throw TypeErrors for match types with no cases if ctx.isTyper
1 parent ed5ddfe commit be4065e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3594,8 +3594,14 @@ class MatchReducer(initctx: Context) extends TypeComparer(initctx) {
35943594
MatchTypeTrace.emptyScrutinee(scrut)
35953595
NoType
35963596
case Nil =>
3597-
val casesText = MatchTypeTrace.noMatchesText(scrut, cases)
3598-
throw MatchTypeReductionError(em"Match type reduction $casesText")
3597+
if ctx.isTyper then
3598+
val casesText = MatchTypeTrace.noMatchesText(scrut, cases)
3599+
throw MatchTypeReductionError(em"Match type reduction $casesText")
3600+
else
3601+
NoType
3602+
/* The match type is left unreduced if an error can not be reported
3603+
* See pos/constvalue-of-failed-match-type.scala for an example
3604+
*/
35993605

36003606
inFrozenConstraint(recur(cases))
36013607
}

0 commit comments

Comments
 (0)