@@ -306,6 +306,9 @@ enum class FixKind : uint8_t {
306306 // / This issue should already have been diagnosed elsewhere.
307307 IgnoreUnresolvedPatternVar,
308308
309+ // / Ignore a nested UnresolvedPatternExpr in an ExprPattern, which is invalid.
310+ IgnoreInvalidPatternInExpr,
311+
309312 // / Resolve type of `nil` by providing a contextual type.
310313 SpecifyContextualTypeForNil,
311314
@@ -2959,6 +2962,33 @@ class IgnoreUnresolvedPatternVar final : public ConstraintFix {
29592962 }
29602963};
29612964
2965+ class IgnoreInvalidPatternInExpr final : public ConstraintFix {
2966+ Pattern *P;
2967+
2968+ IgnoreInvalidPatternInExpr (ConstraintSystem &cs, Pattern *pattern,
2969+ ConstraintLocator *locator)
2970+ : ConstraintFix(cs, FixKind::IgnoreInvalidPatternInExpr, locator),
2971+ P (pattern) {}
2972+
2973+ public:
2974+ std::string getName () const override {
2975+ return " ignore invalid Pattern nested in Expr" ;
2976+ }
2977+
2978+ bool diagnose (const Solution &solution, bool asNote = false ) const override ;
2979+
2980+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override {
2981+ return diagnose (*commonFixes.front ().first );
2982+ }
2983+
2984+ static IgnoreInvalidPatternInExpr *
2985+ create (ConstraintSystem &cs, Pattern *pattern, ConstraintLocator *locator);
2986+
2987+ static bool classof (const ConstraintFix *fix) {
2988+ return fix->getKind () == FixKind::IgnoreInvalidPatternInExpr;
2989+ }
2990+ };
2991+
29622992class SpecifyContextualTypeForNil final : public ConstraintFix {
29632993 SpecifyContextualTypeForNil (ConstraintSystem &cs,
29642994 ConstraintLocator *locator)
0 commit comments