From be4065ea9c57c043ec2fd776ad324f45e6f300aa Mon Sep 17 00:00:00 2001 From: Eugene Flesselle Date: Sun, 17 Mar 2024 09:47:30 +0100 Subject: [PATCH] Only throw TypeErrors for match types with no cases if ctx.isTyper --- compiler/src/dotty/tools/dotc/core/TypeComparer.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index c26512232c6b..56be943292fa 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -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)) }