File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -7989,6 +7989,14 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
79897989 }
79907990 }
79917991
7992+ // `nonisolated` on an actor declaration is contradictory.
7993+ if (auto *classDecl = dyn_cast<ClassDecl>(D);
7994+ classDecl && classDecl->isExplicitActor ()) {
7995+ diagnoseAndRemoveAttr (attr, diag::invalid_decl_modifier, attr)
7996+ .fixItRemove (attr->getRange ());
7997+ return ;
7998+ }
7999+
79928000 if (auto VD = dyn_cast<ValueDecl>(D)) {
79938001 // 'nonisolated(unsafe)' is meaningless for computed properties, functions etc.
79948002 auto var = dyn_cast<VarDecl>(VD);
Original file line number Diff line number Diff line change @@ -53,3 +53,5 @@ extension A2 {
5353
5454 init ( doesNotDelegate: ( ) ) { } // expected-error {{designated initializer cannot be declared in an extension of 'A2'}}
5555}
56+
57+ nonisolated actor A3 { } // expected-error {{'nonisolated' modifier cannot be applied to this declaration}}{{1-13=}}
Original file line number Diff line number Diff line change @@ -65,6 +65,8 @@ distributed actor D5: P1 {
6565 // expected-note@-1{{non-distributed instance method 'dist()'}}
6666}
6767
68+ nonisolated distributed actor D6 { } // expected-error {{'nonisolated' modifier cannot be applied to this declaration}}{{1-13=}}
69+
6870// ==== Tests ------------------------------------------------------------------
6971
7072// Make sure the conformances have been added implicitly.
You can’t perform that action at this time.
0 commit comments