@@ -306,6 +306,9 @@ enum class FixKind : uint8_t {
306
306
// / This issue should already have been diagnosed elsewhere.
307
307
IgnoreUnresolvedPatternVar,
308
308
309
+ // / Ignore a nested UnresolvedPatternExpr in an ExprPattern, which is invalid.
310
+ IgnoreInvalidPatternInExpr,
311
+
309
312
// / Resolve type of `nil` by providing a contextual type.
310
313
SpecifyContextualTypeForNil,
311
314
@@ -2959,6 +2962,33 @@ class IgnoreUnresolvedPatternVar final : public ConstraintFix {
2959
2962
}
2960
2963
};
2961
2964
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
+
2962
2992
class SpecifyContextualTypeForNil final : public ConstraintFix {
2963
2993
SpecifyContextualTypeForNil (ConstraintSystem &cs,
2964
2994
ConstraintLocator *locator)
0 commit comments