Skip to content

Commit 2b80bd2

Browse files
committed
[Concurency] Allow declarations with @isolated(any) parameters be marked as @concurrent/nonisolated(nonsending)
It's shouldn't be possible to use these attributes directly on the function type that is `@isolated(any)` as per SE-0461 proposal but it shouldn't preclude declarations that have parameters with `@isolated(any)` from using them. Resolves: rdar://154754939
1 parent 529a9f8 commit 2b80bd2

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8735,11 +8735,6 @@ ERROR(execution_behavior_incompatible_isolated_parameter,none,
87358735
"an isolated parameter: %2",
87368736
(DeclAttribute, ValueDecl *, ValueDecl *))
87378737

8738-
ERROR(execution_behavior_incompatible_dynamically_isolated_parameter,none,
8739-
"cannot use %0 on %kind1 because it has "
8740-
"a dynamically isolated parameter: %2",
8741-
(DeclAttribute, ValueDecl *, ValueDecl *))
8742-
87438738
ERROR(execution_behavior_attr_incompatible_with_global_isolation,none,
87448739
"cannot use %0 because function type is isolated to a global actor %1",
87458740
(DeclAttribute, Type))

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
228228
attr, decl, P);
229229
return;
230230
}
231-
232-
if (auto *attrType = dyn_cast<AttributedTypeRepr>(repr)) {
233-
if (attrType->has(TypeAttrKind::Isolated)) {
234-
diagnoseAndRemoveAttr(
235-
attr,
236-
diag::
237-
execution_behavior_incompatible_dynamically_isolated_parameter,
238-
attr, decl, P);
239-
return;
240-
}
241-
}
242231
}
243232
}
244233

test/attr/execution_behavior_attrs.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ struct TestAttributeCollisions {
9494
}
9595

9696
@concurrent func testIsolationAny(arg: @isolated(any) () -> Void) async {}
97-
// expected-error@-1 {{cannot use @concurrent on instance method 'testIsolationAny(arg:)' because it has a dynamically isolated parameter: 'arg'}}
9897
@concurrent subscript(testIsolationAny arg: @isolated(any) () -> Void) -> Int {
99-
// expected-error@-1 {{cannot use @concurrent on subscript 'subscript(testIsolationAny:)' because it has a dynamically isolated parameter: 'arg'}}
10098
get async {}
10199
}
102100

@@ -158,3 +156,13 @@ do {
158156
})
159157
}
160158
}
159+
160+
do {
161+
nonisolated(nonsending)
162+
func testOnDecl(_: @isolated(any) () -> Void) async {} // Ok
163+
164+
func testOnType1(_: nonisolated(nonsending) @isolated(any) () async -> Void) {}
165+
// expected-error@-1 {{cannot use 'nonisolated(nonsending)' together with '@isolated(any)'}}
166+
func testOnType2(_: @concurrent @isolated(any) () async -> Void) {}
167+
// expected-error@-1 {{cannot use '@concurrent' together with '@isolated(any)'}}
168+
}

0 commit comments

Comments
 (0)