File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1603,3 +1603,14 @@ IgnoreInvalidFunctionBuilderBody *IgnoreInvalidFunctionBuilderBody::create(
1603
1603
return new (cs.getAllocator ())
1604
1604
IgnoreInvalidFunctionBuilderBody (cs, phase, locator);
1605
1605
}
1606
+
1607
+ bool SpecifyContextualTypeForNil::diagnose (const Solution &solution,
1608
+ bool asNote) const {
1609
+ return false ;
1610
+ }
1611
+
1612
+ SpecifyContextualTypeForNil *
1613
+ SpecifyContextualTypeForNil::create (ConstraintSystem &cs,
1614
+ ConstraintLocator *locator) {
1615
+ return new (cs.getAllocator ()) SpecifyContextualTypeForNil (cs, locator);
1616
+ }
Original file line number Diff line number Diff line change @@ -279,6 +279,9 @@ enum class FixKind : uint8_t {
279
279
280
280
// / Ignore function builder body which fails `pre-check` call.
281
281
IgnoreInvalidFunctionBuilderBody,
282
+
283
+ // / Resolve type of `nil` by providing a contextual type.
284
+ SpecifyContextualTypeForNil,
282
285
};
283
286
284
287
class ConstraintFix {
@@ -2026,6 +2029,26 @@ class IgnoreInvalidFunctionBuilderBody final : public ConstraintFix {
2026
2029
create (ConstraintSystem &cs, ErrorInPhase phase, ConstraintLocator *locator);
2027
2030
};
2028
2031
2032
+ class SpecifyContextualTypeForNil final : public ConstraintFix {
2033
+ SpecifyContextualTypeForNil (ConstraintSystem &cs,
2034
+ ConstraintLocator *locator)
2035
+ : ConstraintFix(cs, FixKind::SpecifyContextualTypeForNil, locator) {}
2036
+
2037
+ public:
2038
+ std::string getName () const override {
2039
+ return " specify contextual type to resolve `nil` literal" ;
2040
+ }
2041
+
2042
+ bool diagnose (const Solution &solution, bool asNote = false ) const override ;
2043
+
2044
+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override {
2045
+ return diagnose (*commonFixes.front ().first );
2046
+ }
2047
+
2048
+ static SpecifyContextualTypeForNil *create (ConstraintSystem & cs,
2049
+ ConstraintLocator * locator);
2050
+ };
2051
+
2029
2052
} // end namespace constraints
2030
2053
} // end namespace swift
2031
2054
You can’t perform that action at this time.
0 commit comments