Skip to content

Commit f686eaf

Browse files
committed
[Concurrency] Flip the implicitly async select in a concurrency error.
This diagnostic was presenting "implicitly async" for explicitly async calls, and vice versa, because the `select` was incorrect.
1 parent 95cff2a commit f686eaf

7 files changed

+17
-17
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5655,7 +5655,7 @@ ERROR(non_sendable_result_type,none,
56555655
"%3 '@objc' %kind2}1 cannot cross actor boundary",
56565656
(Type, unsigned, const ValueDecl *, ActorIsolation))
56575657
ERROR(non_sendable_call_result_type,none,
5658-
"non-sendable type %0 returned by %select{implicitly asynchronous |}1"
5658+
"non-sendable type %0 returned by %select{|implicitly async }1"
56595659
"call to %2 function cannot cross actor boundary",
56605660
(Type, bool, ActorIsolation))
56615661
ERROR(non_sendable_property_type,none,

test/Concurrency/actor_call_implicitly_async.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,23 +353,23 @@ actor Calculator {
353353

354354
@OrangeActor func doSomething() async {
355355
let _ = (await bananaAdd(1))(2)
356-
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by call to global actor 'BananaActor'-isolated function cannot cross actor boundary}}
356+
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by implicitly async call to global actor 'BananaActor'-isolated function cannot cross actor boundary}}
357357
// expected-note@-2{{a function type must be marked '@Sendable' to conform to 'Sendable'}}
358358
let _ = await (await bananaAdd(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}
359-
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by call to global actor 'BananaActor'-isolated function cannot cross actor boundary}}
359+
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by implicitly async call to global actor 'BananaActor'-isolated function cannot cross actor boundary}}
360360
// expected-note@-2{{a function type must be marked '@Sendable' to conform to 'Sendable'}}
361361

362362
let calc = Calculator()
363363

364364
let _ = (await calc.addCurried(1))(2)
365-
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by call to actor-isolated function cannot cross actor boundary}}
365+
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by implicitly async call to actor-isolated function cannot cross actor boundary}}
366366
// expected-note@-2{{a function type must be marked '@Sendable' to conform to 'Sendable'}}
367367
let _ = await (await calc.addCurried(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}
368-
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by call to actor-isolated function cannot cross actor boundary}}
368+
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by implicitly async call to actor-isolated function cannot cross actor boundary}}
369369
// expected-note@-2{{a function type must be marked '@Sendable' to conform to 'Sendable'}}
370370

371371
let plusOne = await calc.addCurried(await calc.add(0, 1))
372-
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by call to actor-isolated function cannot cross actor boundary}}
372+
// expected-warning@-1{{non-sendable type '(Int) -> Int' returned by implicitly async call to actor-isolated function cannot cross actor boundary}}
373373
// expected-note@-2{{a function type must be marked '@Sendable' to conform to 'Sendable'}}
374374
let _ = plusOne(2)
375375
}

test/Concurrency/concurrent_value_checking.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extension A1 {
102102
_ = other.localLet // expected-warning{{non-sendable type 'NotConcurrent' in implicitly asynchronous access to actor-isolated property 'localLet' cannot cross actor boundary}}
103103
// expected-warning@-1 {{expression is 'async' but is not marked with 'await'}}
104104
// expected-note@-2 {{property access is 'async'}}
105-
_ = await other.synchronous() // expected-warning{{non-sendable type 'NotConcurrent?' returned by call to actor-isolated function cannot cross actor boundary}}
105+
_ = await other.synchronous() // expected-warning{{non-sendable type 'NotConcurrent?' returned by implicitly async call to actor-isolated function cannot cross actor boundary}}
106106
_ = await other.asynchronous(nil)
107107
}
108108
}
@@ -182,10 +182,10 @@ func globalTestMain(nc: NotConcurrent) async {
182182
// expected-tns-note @-1 {{sending global actor 'SomeGlobalActor'-isolated 'a' to global actor 'SomeGlobalActor'-isolated global function 'globalAsync' risks causing data races between global actor 'SomeGlobalActor'-isolated and local main actor-isolated uses}}
183183
await globalSync(a) // expected-tns-note {{access can happen concurrently}}
184184
_ = await ClassWithGlobalActorInits(nc)
185-
// expected-warning @-1 {{non-sendable type 'ClassWithGlobalActorInits' returned by call to global actor 'SomeGlobalActor'-isolated function cannot cross actor boundary}}
185+
// expected-warning @-1 {{non-sendable type 'ClassWithGlobalActorInits' returned by implicitly async call to global actor 'SomeGlobalActor'-isolated function cannot cross actor boundary}}
186186
// expected-tns-warning @-2 {{sending 'nc' risks causing data races}}
187187
// expected-tns-note @-3 {{sending main actor-isolated 'nc' to global actor 'SomeGlobalActor'-isolated initializer 'init(_:)' risks causing data races between global actor 'SomeGlobalActor'-isolated and main actor-isolated uses}}
188-
_ = await ClassWithGlobalActorInits() // expected-warning{{non-sendable type 'ClassWithGlobalActorInits' returned by call to global actor 'SomeGlobalActor'-isolated function cannot cross actor boundary}}
188+
_ = await ClassWithGlobalActorInits() // expected-warning{{non-sendable type 'ClassWithGlobalActorInits' returned by implicitly async call to global actor 'SomeGlobalActor'-isolated function cannot cross actor boundary}}
189189
}
190190

191191
@SomeGlobalActor

test/Concurrency/sendable_checking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public actor MyActor: MyProto {
9797
await nonisolatedAsyncFunc1(ns1) // expected-targeted-and-complete-warning{{passing argument of non-sendable type 'NS1' outside of actor-isolated context may introduce data races}}
9898
// expected-tns-warning @-1 {{sending 'ns1' risks causing data races}}
9999
// expected-tns-note @-2 {{sending 'self'-isolated 'ns1' to nonisolated global function 'nonisolatedAsyncFunc1' risks causing data races between nonisolated and 'self'-isolated uses}}
100-
_ = await nonisolatedAsyncFunc2() // expected-warning{{non-sendable type 'NS1' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary}}
100+
_ = await nonisolatedAsyncFunc2() // expected-warning{{non-sendable type 'NS1' returned by call to nonisolated function cannot cross actor boundary}}
101101
}
102102
}
103103

test/Concurrency/transfernonsendable_asynclet.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ func asyncLetWithoutCapture() async {
722722
//
723723
// NOTE: Error below will go away in next commit.
724724
async let x: NonSendableKlass = await returnValueFromMain()
725-
// expected-warning @-1 {{non-sendable type 'NonSendableKlass' returned by implicitly asynchronous call to main actor-isolated function cannot cross actor boundary}}
725+
// expected-warning @-1 {{non-sendable type 'NonSendableKlass' returned by call to main actor-isolated function cannot cross actor boundary}}
726726
let y = await x
727727
await transferToMain(y) // expected-warning {{sending 'y' risks causing data races}}
728728
// expected-note @-1 {{sending 'y' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
@@ -774,7 +774,7 @@ extension NonSendableStruct {
774774
async let subTask6: NonSendableStruct = self
775775
// expected-warning @-1 {{sending 'self' risks causing data races}}
776776
// expected-note @-2 {{sending 'actor'-isolated 'self' into async let risks causing data races between nonisolated and 'actor'-isolated uses}}
777-
// expected-warning @-3 {{non-sendable type 'NonSendableStruct' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary}}
777+
// expected-warning @-3 {{non-sendable type 'NonSendableStruct' returned by call to nonisolated function cannot cross actor boundary}}
778778
_ = await subTask6
779779
}
780780
}

test/Concurrency/transfernonsendable_defer_and_typecheck_only.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func callActorFuncsFromNonisolated(a : A, ns : NonSendable) async {
3434
//deferred-warning@-1{{passing argument of non-sendable type 'NonSendable' into actor-isolated context may introduce data races}}
3535

3636
_ = await a.actorRetsNS()
37-
//expected-warning@-1{{non-sendable type 'NonSendable' returned by implicitly asynchronous call to actor-isolated function cannot cross actor boundary}}
37+
//expected-warning@-1{{non-sendable type 'NonSendable' returned by call to actor-isolated function cannot cross actor boundary}}
3838
}
3939

4040
@available(SwiftStdlib 5.1, *)
@@ -52,7 +52,7 @@ actor A {
5252
//deferred-warning@-1{{passing argument of non-sendable type 'NonSendable' outside of actor-isolated context may introduce data races}}
5353

5454
_ = await retsNS()
55-
//expected-warning@-1{{non-sendable type 'NonSendable' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary}}
55+
//expected-warning@-1{{non-sendable type 'NonSendable' returned by call to nonisolated function cannot cross actor boundary}}
5656
}
5757

5858
func callActorFuncsFromDiffActor(ns : NonSendable, a : A) async {
@@ -62,6 +62,6 @@ actor A {
6262
//deferred-warning@-1{{passing argument of non-sendable type 'NonSendable' into actor-isolated context may introduce data races}}
6363

6464
_ = await a.actorRetsNS()
65-
//expected-warning@-1{{non-sendable type 'NonSendable' returned by implicitly asynchronous call to actor-isolated function cannot cross actor boundary}}
65+
//expected-warning@-1{{non-sendable type 'NonSendable' returned by call to actor-isolated function cannot cross actor boundary}}
6666
}
6767
}

test/Concurrency/transfernonsendable_sending_results.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func asyncLetReabstractionThunkTest() async {
234234
func asyncLetReabstractionThunkTest2() async {
235235
// We emit the error here since we are returning a main actor isolated value.
236236
async let newValue: NonSendableKlass = await getMainActorValueAsync()
237-
// expected-warning @-1 {{non-sendable type 'NonSendableKlass' returned by implicitly asynchronous call to main actor-isolated function cannot cross actor boundary}}
237+
// expected-warning @-1 {{non-sendable type 'NonSendableKlass' returned by call to main actor-isolated function cannot cross actor boundary}}
238238

239239
let _ = await newValue
240240

@@ -257,7 +257,7 @@ func asyncLetReabstractionThunkTest2() async {
257257
@MainActor func asyncLetReabstractionThunkTestGlobalActor2() async {
258258
// We emit the error here since we are returning a main actor isolated value.
259259
async let newValue: NonSendableKlass = await getMainActorValueAsync()
260-
// expected-warning @-1 {{non-sendable type 'NonSendableKlass' returned by implicitly asynchronous call to main actor-isolated function cannot cross actor boundary}}
260+
// expected-warning @-1 {{non-sendable type 'NonSendableKlass' returned by call to main actor-isolated function cannot cross actor boundary}}
261261

262262
let _ = await newValue
263263

0 commit comments

Comments
 (0)