@@ -10565,26 +10565,34 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
10565
10565
if (Context.LangOpts.hasFeature(Feature::InferSendableFromCaptures)) {
10566
10566
auto shouldCheckSendabilityOfBase = [&]() {
10567
10567
if (!Context.getProtocol(KnownProtocolKind::Sendable))
10568
- return false ;
10568
+ return Type() ;
10569
10569
10570
- return llvm::any_of(lookup, [&]( const auto &result) {
10570
+ for ( const auto &result : lookup ) {
10571
10571
auto decl = result.getValueDecl();
10572
10572
if (!isa_and_nonnull<FuncDecl>(decl))
10573
- return false ;
10573
+ continue ;
10574
10574
10575
- if (!decl->isInstanceMember())
10576
- return false;
10575
+ if (!decl->isInstanceMember() &&
10576
+ !decl->getDeclContext()->getSelfProtocolDecl())
10577
+ continue;
10577
10578
10578
10579
auto hasAppliedSelf = decl->hasCurriedSelf() &&
10579
10580
doesMemberRefApplyCurriedSelf(baseObjTy, decl);
10580
10581
auto numApplies = getNumApplications(hasAppliedSelf, functionRefInfo);
10581
- return numApplies < decl->getNumCurryLevels();
10582
- });
10582
+ if (numApplies >= decl->getNumCurryLevels())
10583
+ continue;
10584
+
10585
+ return decl->isInstanceMember()
10586
+ ? instanceTy
10587
+ : MetatypeType::get(instanceTy);
10588
+ }
10589
+
10590
+ return Type();
10583
10591
};
10584
10592
10585
- if (shouldCheckSendabilityOfBase()) {
10593
+ if (Type baseTyToCheck = shouldCheckSendabilityOfBase()) {
10586
10594
auto sendableProtocol = Context.getProtocol(KnownProtocolKind::Sendable);
10587
- auto baseConformance = lookupConformance(instanceTy , sendableProtocol);
10595
+ auto baseConformance = lookupConformance(baseTyToCheck , sendableProtocol);
10588
10596
10589
10597
if (llvm::any_of(
10590
10598
baseConformance.getConditionalRequirements(),
@@ -10593,8 +10601,10 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
10593
10601
return false;
10594
10602
10595
10603
return (req.getFirstType()->hasTypeVariable() &&
10596
- req.getProtocolDecl()->isSpecificProtocol(
10597
- KnownProtocolKind::Sendable));
10604
+ (req.getProtocolDecl()->isSpecificProtocol(
10605
+ KnownProtocolKind::Sendable) ||
10606
+ req.getProtocolDecl()->isSpecificProtocol(
10607
+ KnownProtocolKind::SendableMetatype)));
10598
10608
})) {
10599
10609
result.OverallResult = MemberLookupResult::Unsolved;
10600
10610
return result;
0 commit comments