File tree Expand file tree Collapse file tree 2 files changed +6
-28
lines changed Expand file tree Collapse file tree 2 files changed +6
-28
lines changed Original file line number Diff line number Diff line change @@ -1414,6 +1414,11 @@ FunctionType::ExtInfo ClosureEffectsRequest::evaluate(
1414
1414
bool async = expr->getAsyncLoc ().isValid ();
1415
1415
bool sendable = expr->getAttrs ().hasAttribute <SendableAttr>();
1416
1416
1417
+ // `@concurrent` attribute is only valid on asynchronous function types.
1418
+ if (expr->getAttrs ().hasAttribute <ConcurrentAttr>()) {
1419
+ async = true ;
1420
+ }
1421
+
1417
1422
if (throws || async) {
1418
1423
return ASTExtInfoBuilder ()
1419
1424
.withThrows (throws, /* FIXME:*/ Type ())
@@ -1427,17 +1432,11 @@ FunctionType::ExtInfo ClosureEffectsRequest::evaluate(
1427
1432
if (!body)
1428
1433
return ASTExtInfoBuilder ().withSendable (sendable).build ();
1429
1434
1430
- // `@concurrent` attribute is only valid on asynchronous function types.
1431
- bool asyncFromAttr = false ;
1432
- if (expr->getAttrs ().hasAttribute <ConcurrentAttr>()) {
1433
- asyncFromAttr = true ;
1434
- }
1435
-
1436
1435
auto throwFinder = FindInnerThrows (expr);
1437
1436
body->walk (throwFinder);
1438
1437
return ASTExtInfoBuilder ()
1439
1438
.withThrows (throwFinder.foundThrow (), /* FIXME:*/ Type ())
1440
- .withAsync (asyncFromAttr || bool (findAsyncNode (expr)))
1439
+ .withAsync (bool (findAsyncNode (expr)))
1441
1440
.withSendable (sendable)
1442
1441
.build ();
1443
1442
}
Original file line number Diff line number Diff line change @@ -137,24 +137,3 @@ _ = { @MainActor @concurrent in
137
137
_ = { @concurrent ( ) -> Int in
138
138
// expected-error@-1 {{@concurrent on non-async closure}}
139
139
}
140
-
141
- // Make sure that explicit use of `@concurrent` doesn't interfere with inference of `throws` from the body.
142
- do {
143
- func acceptsThrowing( _ body: ( ) async throws -> Void ) async {
144
- }
145
-
146
- struct Invocation {
147
- func throwingFn( ) async throws {
148
- }
149
- }
150
-
151
- func test( invocation: Invocation ) async {
152
- await acceptsThrowing ( { @concurrent in try await invocation. throwingFn ( ) } ) // Ok
153
- await acceptsThrowing ( { @concurrent [ invocation] in try await invocation. throwingFn ( ) } ) // Ok
154
-
155
- await acceptsThrowing ( { @concurrent in // Ok
156
- _ = 42
157
- try await invocation. throwingFn ( )
158
- } )
159
- }
160
- }
You can’t perform that action at this time.
0 commit comments