File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,10 @@ enum class FixKind : uint8_t {
281
281
282
282
// / Resolve type of `nil` by providing a contextual type.
283
283
SpecifyContextualTypeForNil,
284
+
285
+ // / Allow expressions to reference invalid declarations by turning
286
+ // / them into holes.
287
+ AllowRefToInvalidDecl,
284
288
};
285
289
286
290
class ConstraintFix {
@@ -2055,6 +2059,21 @@ class SpecifyContextualTypeForNil final : public ConstraintFix {
2055
2059
ConstraintLocator * locator);
2056
2060
};
2057
2061
2062
+ class AllowRefToInvalidDecl final : public ConstraintFix {
2063
+ AllowRefToInvalidDecl (ConstraintSystem &cs, ConstraintLocator *locator)
2064
+ : ConstraintFix(cs, FixKind::AllowRefToInvalidDecl, locator) {}
2065
+
2066
+ public:
2067
+ std::string getName () const override {
2068
+ return " ignore invalid declaration reference" ;
2069
+ }
2070
+
2071
+ bool diagnose (const Solution &solution, bool asNote = false ) const override ;
2072
+
2073
+ static AllowRefToInvalidDecl *create (ConstraintSystem &cs,
2074
+ ConstraintLocator *locator);
2075
+ };
2076
+
2058
2077
} // end namespace constraints
2059
2078
} // end namespace swift
2060
2079
Original file line number Diff line number Diff line change @@ -1615,3 +1615,14 @@ SpecifyContextualTypeForNil::create(ConstraintSystem &cs,
1615
1615
ConstraintLocator *locator) {
1616
1616
return new (cs.getAllocator ()) SpecifyContextualTypeForNil (cs, locator);
1617
1617
}
1618
+
1619
+ bool AllowRefToInvalidDecl::diagnose (const Solution &solution,
1620
+ bool asNote) const {
1621
+ return false ;
1622
+ }
1623
+
1624
+ AllowRefToInvalidDecl *
1625
+ AllowRefToInvalidDecl::create (ConstraintSystem &cs,
1626
+ ConstraintLocator *locator) {
1627
+ return new (cs.getAllocator ()) AllowRefToInvalidDecl (cs, locator);
1628
+ }
Original file line number Diff line number Diff line change @@ -10144,7 +10144,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
10144
10144
case FixKind::SpecifyLabelToAssociateTrailingClosure:
10145
10145
case FixKind::AllowKeyPathWithoutComponents:
10146
10146
case FixKind::IgnoreInvalidResultBuilderBody:
10147
- case FixKind::SpecifyContextualTypeForNil: {
10147
+ case FixKind::SpecifyContextualTypeForNil:
10148
+ case FixKind::AllowRefToInvalidDecl: {
10148
10149
return recordFix (fix) ? SolutionKind::Error : SolutionKind::Solved;
10149
10150
}
10150
10151
You can’t perform that action at this time.
0 commit comments