@@ -1665,7 +1665,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
1665
1665
ConstraintLocatorBuilder locator,
1666
1666
DeclContext *useDC) {
1667
1667
auto &ctx = getASTContext ();
1668
-
1668
+
1669
1669
if (value->getDeclContext ()->isTypeContext () && isa<FuncDecl>(value)) {
1670
1670
// Unqualified lookup can find operator names within nominal types.
1671
1671
auto func = cast<FuncDecl>(value);
@@ -1711,14 +1711,16 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
1711
1711
auto funcType = funcDecl->getInterfaceType ()->castTo <AnyFunctionType>();
1712
1712
auto numLabelsToRemove = getNumRemovedArgumentLabels (
1713
1713
funcDecl, /* isCurriedInstanceReference=*/ false , functionRefKind);
1714
-
1714
+
1715
1715
if (ctx.LangOpts .hasFeature (Feature::InferSendableMethods)) {
1716
1716
// All global functions should be @Sendable
1717
- if (funcDecl->getDeclContext ()->isLocalContext ()) {
1718
- funcType = funcType->withExtInfo (funcType->getExtInfo ().withConcurrent ())->getAs <AnyFunctionType>();
1717
+ if (funcDecl->getDeclContext ()->isLocalContext ()) {
1718
+ funcType =
1719
+ funcType->withExtInfo (funcType->getExtInfo ().withConcurrent ())
1720
+ ->getAs <AnyFunctionType>();
1719
1721
}
1720
1722
}
1721
-
1723
+
1722
1724
auto openedType = openFunctionType (funcType, locator, replacements,
1723
1725
funcDecl->getDeclContext ())
1724
1726
->removeArgumentLabels (numLabelsToRemove);
@@ -2641,26 +2643,27 @@ ConstraintSystem::getTypeOfMemberReference(
2641
2643
if (inferredSendable) {
2642
2644
auto sendableProtocol = parentModule->getASTContext ().getProtocol (
2643
2645
KnownProtocolKind::Sendable);
2644
- auto baseConformance = TypeChecker::conformsToProtocol (
2645
- baseOpenedTy, sendableProtocol, parentModule );
2646
+ auto baseConformance =
2647
+ parentModule-> lookupConformance ( baseOpenedTy, sendableProtocol);
2646
2648
2647
2649
if (baseTypeSendable) {
2648
2650
// Add @Sendable to functions without conditional conformances
2649
- if (baseConformance.getConditionalRequirements ().empty ()){
2651
+ if (baseConformance.getConditionalRequirements ().empty ()) {
2650
2652
functionType = functionType->withExtInfo (functionType->getExtInfo ().withConcurrent ())->getAs <FunctionType>();
2651
2653
} else {
2652
2654
// Handle Conditional Conformances
2653
2655
auto substitutionMap = SubstitutionMap::getProtocolSubstitutions (
2654
- sendableProtocol, baseOpenedTy,
2655
- baseConformance);
2656
-
2657
- auto result = TypeChecker::checkGenericArguments (parentModule, baseConformance.getConditionalRequirements (), QuerySubstitutionMap{substitutionMap} );
2658
-
2656
+ sendableProtocol, baseOpenedTy, baseConformance);
2657
+
2658
+ auto result = TypeChecker::checkGenericArguments (
2659
+ parentModule, baseConformance.getConditionalRequirements (),
2660
+ QuerySubstitutionMap{substitutionMap});
2661
+
2659
2662
if (result == CheckGenericArgumentsResult::Success) {
2660
2663
functionType =
2661
- functionType
2662
- ->withExtInfo (functionType->getExtInfo ().withConcurrent ())
2663
- ->getAs <FunctionType>();
2664
+ functionType
2665
+ ->withExtInfo (functionType->getExtInfo ().withConcurrent ())
2666
+ ->getAs <FunctionType>();
2664
2667
}
2665
2668
}
2666
2669
}
@@ -2672,10 +2675,10 @@ ConstraintSystem::getTypeOfMemberReference(
2672
2675
FunctionType::get (fullFunctionType->getParams (), functionType, info);
2673
2676
2674
2677
// Add @Sendable to openedType if possible
2675
- if (inferredSendable){
2678
+ if (inferredSendable) {
2676
2679
auto origFnType = openedType->castTo <FunctionType>();
2677
2680
openedType =
2678
- origFnType->withExtInfo (origFnType->getExtInfo ().withConcurrent ());
2681
+ origFnType->withExtInfo (origFnType->getExtInfo ().withConcurrent ());
2679
2682
}
2680
2683
}
2681
2684
0 commit comments