@@ -5578,25 +5578,47 @@ bool ConstraintSystem::repairFailures(
5578
5578
return false;
5579
5579
}
5580
5580
5581
+ // Be a little lax in protocol requirement matching.
5581
5582
if (auto *VD = getAsDecl<ValueDecl>(anchor)) {
5582
- // Matching a witness to a ObjC protocol requirement.
5583
- if (VD->isObjC() && VD->isProtocolRequirement() &&
5584
- path[0].is<LocatorPathElt::Witness>() &&
5583
+ if (VD->isProtocolRequirement() &&
5584
+ path[0].is<LocatorPathElt::Witness>() &&
5585
5585
// Note that the condition below is very important,
5586
5586
// we need to wait until the very last moment to strip
5587
5587
// the concurrency annotations from the inner most type.
5588
5588
conversionsOrFixes.empty()) {
5589
- // Allow requirements to introduce `swift_attr` annotations
5590
- // (note that `swift_attr` in type contexts weren't supported
5591
- // before) and for witnesses to adopt them gradually by matching
5592
- // with a warning in non-strict concurrency mode.
5593
- if (!(Context.isSwiftVersionAtLeast(6) ||
5589
+ bool hasAdjustments = false;
5590
+ Type strippedLHS = lhs;
5591
+ Type strippedRHS = rhs;
5592
+
5593
+ // When matching to an ObjC protocol requirement, allow requirements
5594
+ // to introduce `swift_attr` annotations (note that `swift_attr` in
5595
+ // type contexts weren't supported before) and for witnesses to
5596
+ // adopt them gradually by matching with a warning in non-strict
5597
+ // concurrency mode.
5598
+ if (VD->isObjC() &&
5599
+ !(Context.isSwiftVersionAtLeast(6) ||
5594
5600
Context.LangOpts.StrictConcurrencyLevel ==
5595
5601
StrictConcurrency::Complete)) {
5596
- auto strippedLHS = lhs->stripConcurrency(/*resursive=*/true,
5597
- /*dropGlobalActor=*/true);
5598
- auto strippedRHS = rhs->stripConcurrency(/*resursive=*/true,
5599
- /*dropGlobalActor=*/true);
5602
+ strippedLHS = lhs->stripConcurrency(/*recursive=*/true,
5603
+ /*dropGlobalActor=*/true);
5604
+ strippedRHS = rhs->stripConcurrency(/*recursive=*/true,
5605
+ /*dropGlobalActor=*/true);
5606
+ hasAdjustments = true;
5607
+ }
5608
+
5609
+ // Always allow @isolated(any) mismatches.
5610
+ auto maybeRemoveIsolatedAny = [&](Type &ty) {
5611
+ if (auto fnType = ty->getAs<AnyFunctionType>();
5612
+ fnType && fnType->getIsolation().isErased()) {
5613
+ ty = fnType->withExtInfo(fnType->getExtInfo()
5614
+ .withIsolation(FunctionTypeIsolation::forNonIsolated()));
5615
+ hasAdjustments = true;
5616
+ }
5617
+ };
5618
+ maybeRemoveIsolatedAny(strippedLHS);
5619
+ maybeRemoveIsolatedAny(strippedRHS);
5620
+
5621
+ if (hasAdjustments) {
5600
5622
auto result = matchTypes(strippedLHS, strippedRHS, matchKind,
5601
5623
flags | TMF_ApplyingFix, locator);
5602
5624
if (!result.isFailure()) {
0 commit comments