File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -331,7 +331,10 @@ enum class FixKind : uint8_t {
331
331
332
332
// / Specify a type for an explicitly written placeholder that could not be
333
333
// / resolved.
334
- SpecifyTypeForPlaceholder
334
+ SpecifyTypeForPlaceholder,
335
+
336
+ // / Allow `weak` declarations to be bound to a non-optional type.
337
+ AllowNonOptionalWeak,
335
338
};
336
339
337
340
class ConstraintFix {
@@ -2424,6 +2427,21 @@ class AllowInvalidStaticMemberRefOnProtocolMetatype final
2424
2427
create (ConstraintSystem &cs, ConstraintLocator *locator);
2425
2428
};
2426
2429
2430
+ class AllowNonOptionalWeak final : public ConstraintFix {
2431
+ AllowNonOptionalWeak (ConstraintSystem &cs, ConstraintLocator *locator)
2432
+ : ConstraintFix(cs, FixKind::AllowNonOptionalWeak, locator) {}
2433
+
2434
+ public:
2435
+ std::string getName () const override {
2436
+ return " allow `weak` with non-optional type" ;
2437
+ }
2438
+
2439
+ bool diagnose (const Solution &solution, bool asNote = false ) const override ;
2440
+
2441
+ static AllowNonOptionalWeak *create (ConstraintSystem &cs,
2442
+ ConstraintLocator *locator);
2443
+ };
2444
+
2427
2445
} // end namespace constraints
2428
2446
} // end namespace swift
2429
2447
Original file line number Diff line number Diff line change @@ -1989,3 +1989,13 @@ AllowInvalidStaticMemberRefOnProtocolMetatype::create(
1989
1989
return new (cs.getAllocator ())
1990
1990
AllowInvalidStaticMemberRefOnProtocolMetatype (cs, locator);
1991
1991
}
1992
+
1993
+ bool AllowNonOptionalWeak::diagnose (const Solution &solution,
1994
+ bool asNote) const {
1995
+ return false ;
1996
+ }
1997
+
1998
+ AllowNonOptionalWeak *AllowNonOptionalWeak::create (ConstraintSystem &cs,
1999
+ ConstraintLocator *locator) {
2000
+ return new (cs.getAllocator ()) AllowNonOptionalWeak (cs, locator);
2001
+ }
Original file line number Diff line number Diff line change @@ -11544,7 +11544,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
11544
11544
case FixKind::AllowInvalidStaticMemberRefOnProtocolMetatype:
11545
11545
case FixKind::AllowWrappedValueMismatch:
11546
11546
case FixKind::RemoveExtraneousArguments:
11547
- case FixKind::SpecifyTypeForPlaceholder: {
11547
+ case FixKind::SpecifyTypeForPlaceholder:
11548
+ case FixKind::AllowNonOptionalWeak: {
11548
11549
return recordFix (fix) ? SolutionKind::Error : SolutionKind::Solved;
11549
11550
}
11550
11551
You can’t perform that action at this time.
0 commit comments