@@ -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
@@ -2963,6 +2966,33 @@ class IgnoreUnresolvedPatternVar final : public ConstraintFix {
29632966 }
29642967};
29652968
2969+ class IgnoreInvalidPatternInExpr final : public ConstraintFix {
2970+ Pattern *P;
2971+
2972+ IgnoreInvalidPatternInExpr (ConstraintSystem &cs, Pattern *pattern,
2973+ ConstraintLocator *locator)
2974+ : ConstraintFix(cs, FixKind::IgnoreInvalidPatternInExpr, locator),
2975+ P (pattern) {}
2976+
2977+ public:
2978+ std::string getName () const override {
2979+ return " ignore invalid Pattern nested in Expr" ;
2980+ }
2981+
2982+ bool diagnose (const Solution &solution, bool asNote = false ) const override ;
2983+
2984+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override {
2985+ return diagnose (*commonFixes.front ().first );
2986+ }
2987+
2988+ static IgnoreInvalidPatternInExpr *
2989+ create (ConstraintSystem &cs, Pattern *pattern, ConstraintLocator *locator);
2990+
2991+ static bool classof (const ConstraintFix *fix) {
2992+ return fix->getKind () == FixKind::IgnoreInvalidPatternInExpr;
2993+ }
2994+ };
2995+
29662996class SpecifyContextualTypeForNil final : public ConstraintFix {
29672997 SpecifyContextualTypeForNil (ConstraintSystem &cs,
29682998 ConstraintLocator *locator)
0 commit comments