mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CSGen] Prevent @concurrent on closures from skipping throws inference
Introduction of `@concurrent` attribute caused an unintended
side-effect in `ClosureEffectsRequest` since the attribute
could only be used on `async` types setting `async` too early
prevented body analysis for `throws` from running.
Resolves: rdar://151421590
(cherry picked from commit cda9866b26)
This commit is contained in:
committed by
Anthony Latsis
parent
5c06176de9
commit
f41e6598d7
@@ -1414,11 +1414,6 @@ FunctionType::ExtInfo ClosureEffectsRequest::evaluate(
|
||||
bool async = expr->getAsyncLoc().isValid();
|
||||
bool sendable = expr->getAttrs().hasAttribute<SendableAttr>();
|
||||
|
||||
// `@concurrent` attribute is only valid on asynchronous function types.
|
||||
if (expr->getAttrs().hasAttribute<ConcurrentAttr>()) {
|
||||
async = true;
|
||||
}
|
||||
|
||||
if (throws || async) {
|
||||
return ASTExtInfoBuilder()
|
||||
.withThrows(throws, /*FIXME:*/Type())
|
||||
@@ -1432,11 +1427,17 @@ FunctionType::ExtInfo ClosureEffectsRequest::evaluate(
|
||||
if (!body)
|
||||
return ASTExtInfoBuilder().withSendable(sendable).build();
|
||||
|
||||
// `@concurrent` attribute is only valid on asynchronous function types.
|
||||
bool asyncFromAttr = false;
|
||||
if (expr->getAttrs().hasAttribute<ConcurrentAttr>()) {
|
||||
asyncFromAttr = true;
|
||||
}
|
||||
|
||||
auto throwFinder = FindInnerThrows(expr);
|
||||
body->walk(throwFinder);
|
||||
return ASTExtInfoBuilder()
|
||||
.withThrows(throwFinder.foundThrow(), /*FIXME:*/Type())
|
||||
.withAsync(bool(findAsyncNode(expr)))
|
||||
.withAsync(asyncFromAttr || bool(findAsyncNode(expr)))
|
||||
.withSendable(sendable)
|
||||
.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user