File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -2358,17 +2358,19 @@ FunctionType::ExtInfo ConstraintSystem::closureEffects(ClosureExpr *expr) {
2358
2358
// set of effects.
2359
2359
bool throws = expr->getThrowsLoc ().isValid ();
2360
2360
bool async = expr->getAsyncLoc ().isValid ();
2361
+ bool concurrent = expr->getAttrs ().hasAttribute <ConcurrentAttr>();
2361
2362
if (throws || async) {
2362
2363
return ASTExtInfoBuilder ()
2363
2364
.withThrows (throws)
2364
2365
.withAsync (async)
2366
+ .withConcurrent (concurrent)
2365
2367
.build ();
2366
2368
}
2367
2369
2368
2370
// Scan the body to determine the effects.
2369
2371
auto body = expr->getBody ();
2370
2372
if (!body)
2371
- return FunctionType::ExtInfo ();
2373
+ return ASTExtInfoBuilder (). withConcurrent (concurrent). build ();
2372
2374
2373
2375
auto throwFinder = FindInnerThrows (*this , expr);
2374
2376
body->walk (throwFinder);
@@ -2377,6 +2379,7 @@ FunctionType::ExtInfo ConstraintSystem::closureEffects(ClosureExpr *expr) {
2377
2379
auto result = ASTExtInfoBuilder ()
2378
2380
.withThrows (throwFinder.foundThrow ())
2379
2381
.withAsync (asyncFinder.foundAsync ())
2382
+ .withConcurrent (concurrent)
2380
2383
.build ();
2381
2384
closureEffectsCache[expr] = result;
2382
2385
return result;
Original file line number Diff line number Diff line change @@ -5482,10 +5482,9 @@ namespace {
5482
5482
class ClosureAttributeChecker
5483
5483
: public AttributeVisitor<ClosureAttributeChecker> {
5484
5484
ASTContext &ctx;
5485
- ClosureExpr *closure;
5486
5485
public:
5487
5486
ClosureAttributeChecker (ClosureExpr *closure)
5488
- : ctx(closure->getASTContext ()), closure(closure) { }
5487
+ : ctx(closure->getASTContext ()) { }
5489
5488
5490
5489
void visitDeclAttribute (DeclAttribute *attr) {
5491
5490
ctx.Diags .diagnose (
@@ -5494,6 +5493,10 @@ class ClosureAttributeChecker
5494
5493
.fixItRemove (attr->getRangeWithAt ());
5495
5494
attr->setInvalid ();
5496
5495
}
5496
+
5497
+ void visitConcurrentAttr (ConcurrentAttr *attr) {
5498
+ // Nothing else to check.
5499
+ }
5497
5500
};
5498
5501
5499
5502
}
Original file line number Diff line number Diff line change @@ -118,3 +118,10 @@ func testCaseNonTrivialValue() {
118
118
119
119
j = 17
120
120
}
121
+
122
+ func testExplicitConcurrentClosure( ) {
123
+ let fn = { @concurrent in
124
+ 17
125
+ }
126
+ let _: String = fn // expected-error{{cannot convert value of type '@concurrent () -> Int' to specified type 'String'}}
127
+ }
You can’t perform that action at this time.
0 commit comments