Skip to content

[concurrency] Standardize sending of non-isolated -> nonisolated to match the keyword 'nonisolated'. #74850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/swift/AST/DiagnosticsSIL.def
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,14 @@ WARNING(warning_int_to_fp_inexact, none,

// Flow-isolation diagnostics
ERROR(isolated_after_nonisolated, none,
"cannot access %1 %2 here in %select{non-isolated initializer|deinitializer}0",
"cannot access %1 %2 here in %select{nonisolated initializer|deinitializer}0",
(bool, DescriptiveDeclKind, DeclName))
NOTE(nonisolated_blame, none, "after %1%2 %3, "
"only non-isolated properties of 'self' can be accessed from "
"only nonisolated properties of 'self' can be accessed from "
"%select{this init|a deinit}0", (bool, StringRef, StringRef, DeclName))
ERROR(isolated_property_mutation_in_nonisolated_context,none,
"actor-isolated %kind0 can not be %select{referenced|mutated}1 "
"from a non-isolated context",
"from a nonisolated context",
(const ValueDecl *, bool))

// Yield usage errors
Expand Down
18 changes: 9 additions & 9 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -5472,16 +5472,16 @@ ERROR(actor_isolated_non_self_reference,none,
"%4 %kind0 can not be "
"%select{referenced|mutated|used 'inout'}1 "
"%select{from outside the actor|on a different actor instance|"
"on a non-isolated actor instance|"
"on a nonisolated actor instance|"
"from a Sendable function|from a Sendable closure|"
"from an 'async let' initializer|from global actor %3|"
"from the main actor|from a non-isolated context|"
"from a non-isolated autoclosure}2",
"from the main actor|from a nonisolated context|"
"from a nonisolated autoclosure}2",
(const ValueDecl *, unsigned, unsigned, Type,
ActorIsolation))
ERROR(distributed_actor_isolated_non_self_reference,none,
"distributed actor-isolated %kind0 can not be accessed from a "
"non-isolated context",
"nonisolated context",
(const ValueDecl *))
ERROR(conflicting_stored_property_isolation,none,
"%select{default|memberwise}0 initializer for %1 cannot be both %2 and %3",
Expand Down Expand Up @@ -5622,7 +5622,7 @@ ERROR(shared_mutable_state_access,none,
"reference to %kind0 is not concurrency-safe because it involves shared "
"mutable state", (const ValueDecl *))
ERROR(shared_mutable_state_decl,none,
"%kind0 is not concurrency-safe because it is non-isolated global shared "
"%kind0 is not concurrency-safe because it is nonisolated global shared "
"mutable state", (const ValueDecl *))
ERROR(shared_immutable_state_decl,none,
"%kind1 is not concurrency-safe because non-'Sendable' type %0 may have "
Expand Down Expand Up @@ -5682,7 +5682,7 @@ NOTE(in_derived_witness, none,
(DescriptiveDeclKind, DeclName, Type))
ERROR(non_sendable_param_type,none,
"non-sendable type %0 %select{passed in call to %3 %kind2|"
"exiting %3 context in call to non-isolated %kind2|"
"exiting %3 context in call to nonisolated %kind2|"
"passed in implicitly asynchronous call to %3 %kind2|"
"in parameter of the protocol requirement satisfied by %3 %kind2|"
"in parameter of superclass method overridden by %3 %kind2|"
Expand All @@ -5694,7 +5694,7 @@ ERROR(non_sendable_call_argument,none,
(Type, bool, ActorIsolation))
ERROR(non_sendable_result_type,none,
"non-sendable type %0 returned by %select{call to %3 %kind2|"
"call from %4 context to non-isolated %kind2|"
"call from %4 context to nonisolated %kind2|"
"implicitly asynchronous call to %3 %kind2|"
"%3 %kind2 satisfying protocol requirement|"
"%3 overriding %kind2|"
Expand All @@ -5707,7 +5707,7 @@ ERROR(non_sendable_call_result_type,none,
ERROR(non_sendable_property_type,none,
"non-sendable type %0 in %select{"
"%select{asynchronous access to %4 %kind1|"
"asynchronous access from %4 context to non-isolated %kind1|"
"asynchronous access from %4 context to nonisolated %kind1|"
"implicitly asynchronous access to %4 %kind1|"
"conformance of %4 %kind1 to protocol requirement|"
"%4 overriding %kind1|"
Expand Down Expand Up @@ -5810,7 +5810,7 @@ ERROR(nonisolated_wrapped_property,none,
())

ERROR(non_sendable_from_deinit,none,
"cannot access %1 %2 with a non-sendable type %0 from non-isolated deinit",
"cannot access %1 %2 with a non-sendable type %0 from nonisolated deinit",
(Type, DescriptiveDeclKind, DeclName))

ERROR(actor_instance_property_wrapper,none,
Expand Down
4 changes: 2 additions & 2 deletions test/ClangImporter/objc_isolation_complete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func unsatisfiedPreconcurrencyIsolation(view: MyView) {
// expected-warning@+1 {{call to main actor-isolated instance method 'display()' in a synchronous nonisolated context}}
view.display()

// expected-warning@+1 {{main actor-isolated property 'isVisible' can not be referenced from a non-isolated context}}
// expected-warning@+1 {{main actor-isolated property 'isVisible' can not be referenced from a nonisolated context}}
_ = view.isVisible
}

Expand All @@ -21,7 +21,7 @@ class IsolatedSub: NXSender {
var mainActorState = 0 // expected-note {{property declared here}}
override func sendAny(_: any Sendable) -> any Sendable {
return mainActorState
// expected-warning@-1 {{main actor-isolated property 'mainActorState' can not be referenced from a non-isolated context}}
// expected-warning@-1 {{main actor-isolated property 'mainActorState' can not be referenced from a nonisolated context}}
}

@MainActor
Expand Down
4 changes: 2 additions & 2 deletions test/Concurrency/actor_call_implicitly_async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func anotherAsyncFunc() async {

_ = b.balance // expected-error {{actor-isolated instance method 'balance()' can not be partially applied}}

a.owner = "cat" // expected-error{{actor-isolated property 'owner' can not be mutated from a non-isolated context}}
a.owner = "cat" // expected-error{{actor-isolated property 'owner' can not be mutated from a nonisolated context}}
// expected-error@+1{{expression is 'async' but is not marked with 'await'}} {{7-7=await }} expected-note@+1{{property access is 'async'}}
_ = b.owner
_ = await b.owner == "cat"
Expand Down Expand Up @@ -454,7 +454,7 @@ func tryEffPropsFromSync() {
_ = effPropA // expected-error{{'async' property access in a function that does not support concurrency}}

// expected-error@+1 {{property access can throw, but it is not marked with 'try' and the error is not handled}}
_ = effPropT // expected-error{{global actor 'BananaActor'-isolated var 'effPropT' can not be referenced from a non-isolated context}}
_ = effPropT // expected-error{{global actor 'BananaActor'-isolated var 'effPropT' can not be referenced from a nonisolated context}}
// NOTE: that we don't complain about async access on `effPropT` because it's not declared async, and we're not in an async context!

// expected-error@+1 {{property access can throw, but it is not marked with 'try' and the error is not handled}}
Expand Down
8 changes: 4 additions & 4 deletions test/Concurrency/actor_defer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ actor Actor {
#if NEGATIVES
nonisolated func testActor_negative() {
defer {
// expected-error @+1 {{actor-isolated property 'actorProperty' can not be mutated from a non-isolated context}}
// expected-error @+1 {{actor-isolated property 'actorProperty' can not be mutated from a nonisolated context}}
actorProperty += 1
}
doSomething()
}

nonisolated func testActor_task_negative() {
Task {
// expected-error @+1 {{actor-isolated property 'actorProperty' can not be mutated from a non-isolated context}}
// expected-error @+1 {{actor-isolated property 'actorProperty' can not be mutated from a nonisolated context}}
defer { actorProperty += 1 }
doSomething()
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func testIsolatedActor_positive(actor: isolated Actor) {
@available(SwiftStdlib 5.1, *)
func testIsolatedActor_negative(actor: Actor) {
defer {
// expected-error @+1 {{actor-isolated property 'actorProperty' can not be mutated from a non-isolated context}}
// expected-error @+1 {{actor-isolated property 'actorProperty' can not be mutated from a nonisolated context}}
actor.actorProperty += 1
}
doSomething()
Expand Down Expand Up @@ -213,7 +213,7 @@ func testIsolatedActor_closure_positive() {
@available(SwiftStdlib 5.1, *)
func testIsolatedActor_closure_negative() {
takeClosureWithNotIsolatedParam { actor in
// expected-error @+1 {{actor-isolated property 'actorProperty' can not be mutated from a non-isolated context}}
// expected-error @+1 {{actor-isolated property 'actorProperty' can not be mutated from a nonisolated context}}
defer { actor.actorProperty += 1 }
doSomething()
}
Expand Down
14 changes: 7 additions & 7 deletions test/Concurrency/actor_existentials.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ func from_isolated_existential2(_ x: isolated any P) async {

func from_nonisolated(_ x: any P) async {
await x.f()
x.prop += 1 // expected-error {{actor-isolated property 'prop' can not be mutated from a non-isolated context}}
x.prop = 100 // expected-error {{actor-isolated property 'prop' can not be mutated from a non-isolated context}}
x.prop += 1 // expected-error {{actor-isolated property 'prop' can not be mutated from a nonisolated context}}
x.prop = 100 // expected-error {{actor-isolated property 'prop' can not be mutated from a nonisolated context}}
}

func from_concrete(_ x: A) async {
x.prop += 1 // expected-error {{actor-isolated property 'prop' can not be mutated from a non-isolated context}}
x.prop = 100 // expected-error {{actor-isolated property 'prop' can not be mutated from a non-isolated context}}
x.prop += 1 // expected-error {{actor-isolated property 'prop' can not be mutated from a nonisolated context}}
x.prop = 100 // expected-error {{actor-isolated property 'prop' can not be mutated from a nonisolated context}}
}

func from_isolated_concrete(_ x: isolated A) async {
Expand All @@ -53,7 +53,7 @@ nonisolated let act = Act()

func bad() async {
// expected-warning@+2 {{no 'async' operations occur within 'await' expression}}
// expected-error@+1 {{actor-isolated property 'i' can not be mutated from a non-isolated context}}
// expected-error@+1 {{actor-isolated property 'i' can not be mutated from a nonisolated context}}
await act.i = 666
}

Expand All @@ -64,11 +64,11 @@ extension Act: Proto {}

func good() async {
// expected-warning@+2 {{no 'async' operations occur within 'await' expression}}
// expected-error@+1 {{actor-isolated property 'i' can not be mutated from a non-isolated context}}
// expected-error@+1 {{actor-isolated property 'i' can not be mutated from a nonisolated context}}
await (act as any Proto).i = 42
let aIndirect: any Proto = act

// expected-warning@+2 {{no 'async' operations occur within 'await' expression}}
// expected-error@+1 {{actor-isolated property 'i' can not be mutated from a non-isolated context}}
// expected-error@+1 {{actor-isolated property 'i' can not be mutated from a nonisolated context}}
await aIndirect.i = 777
}
12 changes: 6 additions & 6 deletions test/Concurrency/actor_inout_isolation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extension TestActor {
func passStateIntoDifferentClassMethod() async {
let other = NonAsyncClass()
let otherCurry = other.modifyOtherAsync
// expected-targeted-complete-tns-warning @-1 {{non-sendable type 'NonAsyncClass' exiting actor-isolated context in call to non-isolated instance method 'modifyOtherAsync' cannot cross actor boundary}}
// expected-targeted-complete-tns-warning @-1 {{non-sendable type 'NonAsyncClass' exiting actor-isolated context in call to nonisolated instance method 'modifyOtherAsync' cannot cross actor boundary}}
await other.modifyOtherAsync(&value2)
// expected-error @-1 {{actor-isolated property 'value2' cannot be passed 'inout' to 'async' function call}}

Expand Down Expand Up @@ -194,7 +194,7 @@ actor MyActor {

// expected-error@+1{{cannot pass immutable value of type 'Int' as inout argument}}
await modifyAsynchronously(&(maybePoint?.z)!)
// expected-error@+2{{actor-isolated property 'position' can not be used 'inout' on a non-isolated actor instance}}
// expected-error@+2{{actor-isolated property 'position' can not be used 'inout' on a nonisolated actor instance}}
// expected-error@+1{{actor-isolated property 'myActor' cannot be passed 'inout' to 'async' function call}}
await modifyAsynchronously(&myActor.position.x)
}
Expand All @@ -219,8 +219,8 @@ struct MyGlobalActor {
if #available(SwiftStdlib 5.1, *) {
let _ = Task.detached { await { (_ foo: inout Int) async in foo += 1 }(&number) }
// expected-error @-1 {{actor-isolated var 'number' cannot be passed 'inout' to 'async' function call}}
// expected-minimal-error @-2 {{global actor 'MyGlobalActor'-isolated var 'number' can not be used 'inout' from a non-isolated context}}
// expected-complete-tns-error @-3 {{main actor-isolated var 'number' can not be used 'inout' from a non-isolated context}}
// expected-minimal-error @-2 {{global actor 'MyGlobalActor'-isolated var 'number' can not be used 'inout' from a nonisolated context}}
// expected-complete-tns-error @-3 {{main actor-isolated var 'number' can not be used 'inout' from a nonisolated context}}
}

// attempt to pass global state owned by the global actor to another async function
Expand Down Expand Up @@ -288,11 +288,11 @@ actor ProtectArray {
func test() async {
// FIXME: this is invalid too!
_ = await array.mutateAsynchronously
// expected-targeted-complete-tns-warning@-1 {{non-sendable type '@lvalue [Int]' exiting actor-isolated context in call to non-isolated property 'mutateAsynchronously' cannot cross actor boundary}}
// expected-targeted-complete-tns-warning@-1 {{non-sendable type '@lvalue [Int]' exiting actor-isolated context in call to nonisolated property 'mutateAsynchronously' cannot cross actor boundary}}

_ = await array[mutateAsynchronously: 0]
// expected-error@-1 {{actor-isolated property 'array' cannot be passed 'inout' to 'async' function call}}
// expected-targeted-complete-tns-warning@-2 {{non-sendable type 'inout Array<Int>' exiting actor-isolated context in call to non-isolated subscript 'subscript(mutateAsynchronously:)' cannot cross actor boundary}}
// expected-targeted-complete-tns-warning@-2 {{non-sendable type 'inout Array<Int>' exiting actor-isolated context in call to nonisolated subscript 'subscript(mutateAsynchronously:)' cannot cross actor boundary}}

await passToAsync(array[0])

Expand Down
Loading