@@ -2426,6 +2426,41 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
2426
2426
return type;
2427
2427
}
2428
2428
2429
+
2430
+ bool isPartialApplication (ConstraintSystem &cs,
2431
+ const AbstractFunctionDecl *member,
2432
+ ConstraintLocator *locator) {
2433
+ // If this is a compiler synthesized implicit conversion, let's skip
2434
+ // the check because the base of `UDE` is not the base of the injected
2435
+ // initializer.
2436
+ if (locator->isLastElement <LocatorPathElt::ConstructorMember>() &&
2437
+ locator->findFirst <LocatorPathElt::ImplicitConversion>())
2438
+ return false ;
2439
+
2440
+ auto *UDE = getAsExpr<UnresolvedDotExpr>(locator->getAnchor ());
2441
+ if (UDE == nullptr )
2442
+ return false ;
2443
+
2444
+ auto baseTy =
2445
+ cs.simplifyType (cs.getType (UDE->getBase ()))->getWithoutSpecifierType ();
2446
+
2447
+ // If base is a metatype it would be ignored (unless this is an initializer
2448
+ // call), but if it is some other type it means that we have a single
2449
+ // application level already.
2450
+ unsigned level = 0 ;
2451
+ if (!baseTy->is <MetatypeType>())
2452
+ ++level;
2453
+
2454
+ if (auto *call = dyn_cast_or_null<CallExpr>(cs.getParentExpr (UDE))) {
2455
+ level += 1 ;
2456
+ }
2457
+
2458
+ if (level == 2 )
2459
+ return false ;
2460
+
2461
+ return true ;
2462
+ }
2463
+
2429
2464
DeclReferenceType
2430
2465
ConstraintSystem::getTypeOfMemberReference (
2431
2466
Type baseTy, ValueDecl *value, DeclContext *useDC,
@@ -2636,36 +2671,21 @@ ConstraintSystem::getTypeOfMemberReference(
2636
2671
functionType, locator);
2637
2672
auto &ctx = DC->getASTContext ();
2638
2673
auto *parentModule = useDC->getParentModule ();
2639
- bool baseTypeSendable = isSendableType (parentModule, baseOpenedTy);
2640
2674
bool inferredSendable =
2641
2675
ctx.LangOpts .hasFeature (Feature::InferSendableMethods);
2642
2676
2643
- if (inferredSendable) {
2644
- auto sendableProtocol = parentModule->getASTContext ().getProtocol (
2645
- KnownProtocolKind::Sendable);
2646
- auto baseConformance =
2647
- parentModule->lookupConformance (baseOpenedTy, sendableProtocol);
2648
-
2649
- if (baseTypeSendable) {
2677
+ bool isPartialApply;
2678
+ isPartialApply = isPartialApplication (*this , funcDecl, locator);
2679
+
2680
+ if (inferredSendable && isPartialApply) {
2681
+ // auto sendableProtocol = parentModule->getASTContext().getProtocol(
2682
+ // KnownProtocolKind::Sendable);
2683
+ // auto baseConformance =
2684
+ // parentModule->lookupConformance(baseOpenedTy, sendableProtocol);
2685
+
2686
+ if (isSendableType (parentModule, baseOpenedTy)) {
2650
2687
// Add @Sendable to functions without conditional conformances
2651
- if (baseConformance.getConditionalRequirements ().empty ()) {
2652
- functionType = functionType->withExtInfo (functionType->getExtInfo ().withConcurrent ())->getAs <FunctionType>();
2653
- } else {
2654
- // Handle Conditional Conformances
2655
- auto substitutionMap = SubstitutionMap::getProtocolSubstitutions (
2656
- sendableProtocol, baseOpenedTy, baseConformance);
2657
-
2658
- auto result = TypeChecker::checkGenericArguments (
2659
- parentModule, baseConformance.getConditionalRequirements (),
2660
- QuerySubstitutionMap{substitutionMap});
2661
-
2662
- if (result == CheckGenericArgumentsResult::Success) {
2663
- functionType =
2664
- functionType
2665
- ->withExtInfo (functionType->getExtInfo ().withConcurrent ())
2666
- ->getAs <FunctionType>();
2667
- }
2668
- }
2688
+ functionType = functionType->withExtInfo (functionType->getExtInfo ().withConcurrent ())->getAs <FunctionType>();
2669
2689
}
2670
2690
}
2671
2691
0 commit comments