@@ -3023,9 +3023,13 @@ namespace {
3023
3023
if (mayExecuteConcurrentlyWith (
3024
3024
localFunc.getAsDeclContext (), getDeclContext ()) ||
3025
3025
(explicitClosure && explicitClosure->isPassedToSendingParameter ())) {
3026
- GenericSignature genericSig;
3027
- if (auto afd = localFunc.getAbstractFunctionDecl ())
3028
- genericSig = afd->getGenericSignature ();
3026
+ auto innermostGenericDC = localFunc.getAsDeclContext ();
3027
+ while (innermostGenericDC && !innermostGenericDC->isGenericContext ())
3028
+ innermostGenericDC = innermostGenericDC->getParent ();
3029
+
3030
+ GenericSignature genericSig = innermostGenericDC
3031
+ ? innermostGenericDC->getGenericSignatureOfContext ()
3032
+ : GenericSignature ();
3029
3033
3030
3034
for (const auto &capturedType :
3031
3035
localFunc.getCaptureInfo ().getCapturedTypes ()) {
@@ -3036,8 +3040,6 @@ namespace {
3036
3040
->getDepth ();
3037
3041
} else if (type->isTypeParameter ()) {
3038
3042
genericDepth = type->getRootGenericParam ()->getDepth ();
3039
-
3040
- type = localFunc.getAsDeclContext ()->mapTypeIntoContext (type);
3041
3043
} else {
3042
3044
continue ;
3043
3045
}
@@ -3048,6 +3050,9 @@ namespace {
3048
3050
genericDepth < genericSig.getNextDepth () - 1 )
3049
3051
continue ;
3050
3052
3053
+ if (type->isTypeParameter () && innermostGenericDC)
3054
+ type = innermostGenericDC->mapTypeIntoContext (type);
3055
+
3051
3056
// Check that the metatype is sendable.
3052
3057
SendableCheckContext sendableContext (getDeclContext (), preconcurrency);
3053
3058
diagnoseNonSendableTypes (MetatypeType::get (type),
0 commit comments