@@ -9532,34 +9532,6 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
9532
9532
}
9533
9533
}
9534
9534
9535
- // Delay solving member constraint for unapplied methods
9536
- // where the base type has a conditional Sendable conformance
9537
- if (Context.LangOpts.hasFeature(Feature::InferSendableFromCaptures)) {
9538
- if (isPartialApplication(memberLocator)) {
9539
- auto sendableProtocol = Context.getProtocol(KnownProtocolKind::Sendable);
9540
- auto baseConformance = DC->getParentModule()->lookupConformance(
9541
- instanceTy, sendableProtocol);
9542
-
9543
- if (llvm::any_of(
9544
- baseConformance.getConditionalRequirements(),
9545
- [&](const auto &req) {
9546
- if (req.getKind() != RequirementKind::Conformance)
9547
- return false;
9548
-
9549
- if (auto protocolTy =
9550
- req.getSecondType()->template getAs<ProtocolType>()) {
9551
- return req.getFirstType()->hasTypeVariable() &&
9552
- protocolTy->getDecl()->isSpecificProtocol(
9553
- KnownProtocolKind::Sendable);
9554
- }
9555
- return false;
9556
- })) {
9557
- result.OverallResult = MemberLookupResult::Unsolved;
9558
- return result;
9559
- }
9560
- }
9561
- }
9562
-
9563
9535
// Okay, start building up the result list.
9564
9536
result.OverallResult = MemberLookupResult::HasResults;
9565
9537
@@ -10078,6 +10050,46 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
10078
10050
return OverloadChoice(baseTy, cand, functionRefKind);
10079
10051
};
10080
10052
10053
+ // Delay solving member constraint for unapplied methods
10054
+ // where the base type has a conditional Sendable conformance
10055
+ if (Context.LangOpts.hasFeature(Feature::InferSendableFromCaptures)) {
10056
+ auto shouldCheckSendabilityOfBase = [&]() {
10057
+ // Static members are always sendable because they only capture
10058
+ // metatypes which are Sendable.
10059
+ if (baseObjTy->is<AnyMetatypeType>())
10060
+ return false;
10061
+
10062
+ return isPartialApplication(memberLocator) &&
10063
+ llvm::any_of(lookup, [&](const auto &result) {
10064
+ return isa_and_nonnull<FuncDecl>(result.getValueDecl());
10065
+ });
10066
+ };
10067
+
10068
+ if (shouldCheckSendabilityOfBase()) {
10069
+ auto sendableProtocol = Context.getProtocol(KnownProtocolKind::Sendable);
10070
+ auto baseConformance = DC->getParentModule()->lookupConformance(
10071
+ instanceTy, sendableProtocol);
10072
+
10073
+ if (llvm::any_of(
10074
+ baseConformance.getConditionalRequirements(),
10075
+ [&](const auto &req) {
10076
+ if (req.getKind() != RequirementKind::Conformance)
10077
+ return false;
10078
+
10079
+ if (auto protocolTy =
10080
+ req.getSecondType()->template getAs<ProtocolType>()) {
10081
+ return req.getFirstType()->hasTypeVariable() &&
10082
+ protocolTy->getDecl()->isSpecificProtocol(
10083
+ KnownProtocolKind::Sendable);
10084
+ }
10085
+ return false;
10086
+ })) {
10087
+ result.OverallResult = MemberLookupResult::Unsolved;
10088
+ return result;
10089
+ }
10090
+ }
10091
+ }
10092
+
10081
10093
// Add all results from this lookup.
10082
10094
for (auto result : lookup)
10083
10095
addChoice(getOverloadChoice(result.getValueDecl(),
0 commit comments