@@ -1592,8 +1592,9 @@ Pattern *TypeChecker::coercePatternToType(
1592
1592
parentTy->getAnyNominal () == type->getAnyNominal ()) {
1593
1593
enumTy = type;
1594
1594
} else {
1595
- diags.diagnose (EEP->getLoc (), diag::ambiguous_enum_pattern_type,
1596
- parentTy, type);
1595
+ if (!type->hasError ())
1596
+ diags.diagnose (EEP->getLoc (), diag::ambiguous_enum_pattern_type,
1597
+ parentTy, type);
1597
1598
return nullptr ;
1598
1599
}
1599
1600
}
@@ -1699,15 +1700,17 @@ Pattern *TypeChecker::coercePatternToType(
1699
1700
Type elementType = type->getOptionalObjectType ();
1700
1701
1701
1702
if (elementType.isNull ()) {
1702
- auto diagID = diag::optional_element_pattern_not_valid_type;
1703
- SourceLoc loc = OP->getQuestionLoc ();
1704
- // Produce tailored diagnostic for if/let and other conditions.
1705
- if (OP->isImplicit ()) {
1706
- diagID = diag::condition_optional_element_pattern_not_valid_type;
1707
- loc = OP->getLoc ();
1708
- }
1703
+ if (!type->hasError ()) {
1704
+ auto diagID = diag::optional_element_pattern_not_valid_type;
1705
+ SourceLoc loc = OP->getQuestionLoc ();
1706
+ // Produce tailored diagnostic for if/let and other conditions.
1707
+ if (OP->isImplicit ()) {
1708
+ diagID = diag::condition_optional_element_pattern_not_valid_type;
1709
+ loc = OP->getLoc ();
1710
+ }
1709
1711
1710
- diags.diagnose (loc, diagID, type);
1712
+ diags.diagnose (loc, diagID, type);
1713
+ }
1711
1714
return nullptr ;
1712
1715
}
1713
1716
0 commit comments