mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix crash involving captured-type checking for sendable metatypes
(cherry picked from commit e4f1b62c57)
This commit is contained in:
@@ -3024,9 +3024,13 @@ namespace {
|
||||
if (mayExecuteConcurrentlyWith(
|
||||
localFunc.getAsDeclContext(), getDeclContext()) ||
|
||||
(explicitClosure && explicitClosure->isPassedToSendingParameter())) {
|
||||
GenericSignature genericSig;
|
||||
if (auto afd = localFunc.getAbstractFunctionDecl())
|
||||
genericSig = afd->getGenericSignature();
|
||||
auto innermostGenericDC = localFunc.getAsDeclContext();
|
||||
while (innermostGenericDC && !innermostGenericDC->isGenericContext())
|
||||
innermostGenericDC = innermostGenericDC->getParent();
|
||||
|
||||
GenericSignature genericSig = innermostGenericDC
|
||||
? innermostGenericDC->getGenericSignatureOfContext()
|
||||
: GenericSignature();
|
||||
|
||||
for (const auto &capturedType :
|
||||
localFunc.getCaptureInfo().getCapturedTypes()) {
|
||||
@@ -3037,8 +3041,6 @@ namespace {
|
||||
->getDepth();
|
||||
} else if (type->isTypeParameter()) {
|
||||
genericDepth = type->getRootGenericParam()->getDepth();
|
||||
|
||||
type = localFunc.getAsDeclContext()->mapTypeIntoContext(type);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@@ -3049,6 +3051,9 @@ namespace {
|
||||
genericDepth < genericSig.getNextDepth() - 1)
|
||||
continue;
|
||||
|
||||
if (type->isTypeParameter() && innermostGenericDC)
|
||||
type = innermostGenericDC->mapTypeIntoContext(type);
|
||||
|
||||
// Check that the metatype is sendable.
|
||||
SendableCheckContext sendableContext(getDeclContext(), preconcurrency);
|
||||
diagnoseNonSendableTypes(MetatypeType::get(type),
|
||||
|
||||
Reference in New Issue
Block a user