Skip to content

Commit a864c55

Browse files
committed
Update remaining test cases
1 parent 6dd87a2 commit a864c55

File tree

4 files changed

+30
-51
lines changed

4 files changed

+30
-51
lines changed

test/Concurrency/actor_call_implicitly_async.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ actor BankAccount {
2121
// expected-note@+1 {{calls to instance method 'balance()' from outside of its actor context are implicitly asynchronous}}
2222
func balance() -> Int { return curBalance }
2323

24-
// expected-note@+1 {{calls to instance method 'deposit' from outside of its actor context are implicitly asynchronous}}
24+
// expected-note@+1 2{{calls to instance method 'deposit' from outside of its actor context are implicitly asynchronous}}
2525
func deposit(_ amount : Int) -> Int {
2626
guard amount >= 0 else { return 0 }
2727

@@ -125,14 +125,12 @@ func anotherAsyncFunc() async {
125125

126126
}
127127

128-
// expected-note@+2 {{add 'async' to function 'regularFunc()' to make it asynchronous}} {{19-19= async}}
129-
// expected-note@+1 {{add '@asyncHandler' to function 'regularFunc()' to create an implicit asynchronous context}} {{1-1=@asyncHandler }}
130128
func regularFunc() {
131129
let a = BankAccount(initialDeposit: 34)
132130

133131
_ = a.deposit //expected-error{{actor-isolated instance method 'deposit' can only be referenced inside the actor}}
134132

135-
_ = a.deposit(1) // expected-error{{'async' in a function that does not support concurrency}}
133+
_ = a.deposit(1) // expected-error{{actor-isolated instance method 'deposit' can only be referenced inside the actor}}
136134
}
137135

138136

test/Concurrency/async_let_isolation.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@ actor MyActor {
55
let immutable: Int = 17
66
var text: [String] = []
77

8-
func synchronous() -> String { text.first ?? "nothing" } // expected-note 2 {{calls to instance method 'synchronous()' from outside of its actor context are implicitly asynchronous}}
8+
func synchronous() -> String { text.first ?? "nothing" }
99
func asynchronous() async -> String { synchronous() }
1010

1111
func testAsyncLetIsolation() async {
1212
async let x = self.synchronous()
13-
// expected-error @-1{{actor-isolated instance method 'synchronous()' cannot be referenced from 'async let' initializer}}
1413

1514
async let y = await self.asynchronous()
1615

1716
async let z = synchronous()
18-
// expected-error @-1{{actor-isolated instance method 'synchronous()' cannot be referenced from 'async let' initializer}}
1917

2018
var localText = text
21-
async let w = localText.removeLast()
22-
// expected-error@-1{{mutation of captured var 'localText' in concurrently-executing code}}
19+
async let w = localText.removeLast() // expected-error{{mutation of captured var 'localText' in concurrently-executing code}}
2320

2421
_ = await x
2522
_ = await y

test/Concurrency/global_actor_from_ordinary_context.swift

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ func referenceAsyncGlobalActor() {
5656
}
5757

5858

59-
// expected-note@+3 {{add '@asyncHandler' to function 'callGlobalActor()' to create an implicit asynchronous context}} {{1-1=@asyncHandler }}
60-
// expected-note@+2 {{add 'async' to function 'callGlobalActor()' to make it asynchronous}} {{23-23= async}}
6159
// expected-note@+1 {{add '@SomeGlobalActor' to make global function 'callGlobalActor()' part of global actor 'SomeGlobalActor'}} {{1-1=@SomeGlobalActor }}
6260
func callGlobalActor() {
63-
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
61+
syncGlobActorFn() // expected-error {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
6462
}
6563

6664
func fromClosure() {
@@ -70,40 +68,36 @@ func fromClosure() {
7068
x()
7169
}()
7270

73-
// expected-error@+2 {{'async' in a function that does not support concurrency}}
7471
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
7572
let _ = { syncGlobActorFn() }()
7673
}
7774

7875
class Taylor {
79-
init() { // expected-note {{add 'async' to function 'init()' to make it asynchronous}} {{9-9= async}}
80-
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
76+
init() {
77+
syncGlobActorFn() // expected-error {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
8178

8279
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
8380
_ = syncGlobActorFn
8481
}
8582

8683
deinit {
87-
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
84+
syncGlobActorFn() // expected-error {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
8885

8986
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
9087
_ = syncGlobActorFn
9188
}
9289

93-
// expected-note@+3 2 {{add '@SomeGlobalActor' to make instance method 'method1()' part of global actor 'SomeGlobalActor'}} {{3-3=@SomeGlobalActor }}
94-
// expected-note@+2 {{add '@asyncHandler' to function 'method1()' to create an implicit asynchronous context}} {{3-3=@asyncHandler }}
95-
// expected-note@+1 {{add 'async' to function 'method1()' to make it asynchronous}} {{17-17= async}}
90+
// expected-note@+1 2 {{add '@SomeGlobalActor' to make instance method 'method1()' part of global actor 'SomeGlobalActor'}} {{3-3=@SomeGlobalActor }}
9691
func method1() {
97-
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
92+
syncGlobActorFn() // expected-error {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
9893

9994
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
10095
_ = syncGlobActorFn
10196
}
10297

103-
// expected-note@+2 2 {{add '@SomeGlobalActor' to make instance method 'cannotBeHandler()' part of global actor 'SomeGlobalActor'}} {{3-3=@SomeGlobalActor }}
104-
// expected-note@+1 {{add 'async' to function 'cannotBeHandler()' to make it asynchronous}}
98+
// expected-note@+1 2 {{add '@SomeGlobalActor' to make instance method 'cannotBeHandler()' part of global actor 'SomeGlobalActor'}} {{3-3=@SomeGlobalActor }}
10599
func cannotBeHandler() -> Int {
106-
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
100+
syncGlobActorFn() // expected-error {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
107101

108102
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
109103
_ = syncGlobActorFn

test/Concurrency/global_actor_inference.swift

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,20 @@ protocol P2 {
4343
}
4444

4545
class C1: P1 {
46-
func method() { } // expected-note {{calls to instance method 'method()' from outside of its actor context are implicitly asynchronous}}
46+
func method() { } // expected-note 2 {{calls to instance method 'method()' from outside of its actor context are implicitly asynchronous}}
4747

48-
// expected-note@+2 {{add '@asyncHandler' to function 'testMethod()' to create an implicit asynchronous context}} {{3-3=@asyncHandler }}
49-
// expected-note@+1 {{add 'async' to function 'testMethod()' to make it asynchronous}} {{38-38= async}}
5048
@OtherGlobalActor func testMethod() {
51-
method() // expected-error {{'async' in a function that does not support concurrency}}
49+
method() // expected-error {{instance method 'method()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
5250
_ = method // expected-error {{instance method 'method()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
5351
}
5452
}
5553

5654
class C2: P2 {
57-
func method1() { } // expected-note{{calls to instance method 'method1()' from outside of its actor context are implicitly asynchronous}}
55+
func method1() { } // expected-note 2{{calls to instance method 'method1()' from outside of its actor context are implicitly asynchronous}}
5856
func method2() { }
5957

60-
// expected-note@+2 {{add '@asyncHandler' to function 'testMethod()' to create an implicit asynchronous context}} {{3-3=@asyncHandler }}
61-
// expected-note@+1 {{add 'async' to function 'testMethod()' to make it asynchronous}} {{38-38= async}}
6258
@OtherGlobalActor func testMethod() {
63-
method1() // expected-error{{'async' in a function that does not support concurrency}}
59+
method1() // expected-error{{instance method 'method1()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
6460
_ = method1 // expected-error{{instance method 'method1()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
6561
method2() // okay
6662
}
@@ -70,49 +66,47 @@ class C2: P2 {
7066
// Global actor inference for classes and extensions
7167
// ----------------------------------------------------------------------
7268
@SomeGlobalActor class C3 {
73-
func method1() { } // expected-note {{calls to instance method 'method1()' from outside of its actor context are implicitly asynchronous}}
69+
func method1() { } // expected-note 2{{calls to instance method 'method1()' from outside of its actor context are implicitly asynchronous}}
7470
}
7571

7672
extension C3 {
77-
func method2() { } // expected-note {{calls to instance method 'method2()' from outside of its actor context are implicitly asynchronous}}
73+
func method2() { } // expected-note 2{{calls to instance method 'method2()' from outside of its actor context are implicitly asynchronous}}
7874
}
7975

8076
class C4: C3 {
81-
func method3() { } // expected-note {{calls to instance method 'method3()' from outside of its actor context are implicitly asynchronous}}
77+
func method3() { } // expected-note 2{{calls to instance method 'method3()' from outside of its actor context are implicitly asynchronous}}
8278
}
8379

8480
extension C4 {
85-
func method4() { } // expected-note {{calls to instance method 'method4()' from outside of its actor context are implicitly asynchronous}}
81+
func method4() { } // expected-note 2{{calls to instance method 'method4()' from outside of its actor context are implicitly asynchronous}}
8682
}
8783

8884
class C5 {
8985
func method1() { }
9086
}
9187

9288
@SomeGlobalActor extension C5 {
93-
func method2() { } // expected-note {{calls to instance method 'method2()' from outside of its actor context are implicitly asynchronous}}
89+
func method2() { } // expected-note 2{{calls to instance method 'method2()' from outside of its actor context are implicitly asynchronous}}
9490
}
9591

96-
// expected-note@+2 5 {{add '@asyncHandler' to function 'testGlobalActorInference(c3:c4:c5:)' to create an implicit asynchronous context}} {{1-1=@asyncHandler }}
97-
// expected-note@+1 5 {{add 'async' to function 'testGlobalActorInference(c3:c4:c5:)' to make it asynchronous}} {{72-72= async}}
9892
@OtherGlobalActor func testGlobalActorInference(c3: C3, c4: C4, c5: C5) {
9993
// Propagation via class annotation
100-
c3.method1() // expected-error{{'async' in a function that does not support concurrency}}
101-
c3.method2() // expected-error{{'async' in a function that does not support concurrency}}
94+
c3.method1() // expected-error{{instance method 'method1()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
95+
c3.method2() // expected-error{{instance method 'method2()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
10296

10397
_ = c3.method1 // expected-error{{instance method 'method1()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
10498
_ = c3.method2 // expected-error{{instance method 'method2()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
10599

106100
// Propagation via subclassing
107-
c4.method3() // expected-error{{'async' in a function that does not support concurrency}}
108-
c4.method4() // expected-error{{'async' in a function that does not support concurrency}}
101+
c4.method3() // expected-error{{instance method 'method3()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
102+
c4.method4() // expected-error{{instance method 'method4()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
109103

110104
_ = c4.method3 // expected-error{{instance method 'method3()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
111105
_ = c4.method4 // expected-error{{instance method 'method4()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
112106

113107
// Propagation in an extension.
114108
c5.method1() // OK: no propagation
115-
c5.method2() // expected-error{{'async' in a function that does not support concurrency}}
109+
c5.method2() // expected-error{{instance method 'method2()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
116110

117111
_ = c5.method1 // OK
118112
_ = c5.method2 // expected-error{{instance method 'method2()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
@@ -150,15 +144,13 @@ actor GenericSuper<T> {
150144
}
151145

152146
actor GenericSub<T> : GenericSuper<[T]> {
153-
override func method() { } // expected-note{{calls to instance method 'method()' from outside of its actor context are implicitly asynchronous}}
147+
override func method() { } // expected-note 2{{calls to instance method 'method()' from outside of its actor context are implicitly asynchronous}}
154148

155149
@GenericGlobalActor<T> override func method2() { } // expected-error{{global actor 'GenericGlobalActor<T>'-isolated instance method 'method2()' has different actor isolation from global actor 'GenericGlobalActor<[T]>'-isolated overridden declaration}}
156150
@actorIndependent override func method3() { } // expected-error{{actor-independent instance method 'method3()' has different actor isolation from global actor 'GenericGlobalActor<[T]>'-isolated overridden declaration}}
157151

158-
// expected-note@+2 {{add '@asyncHandler' to function 'testMethod()' to create an implicit asynchronous context}} {{3-3=@asyncHandler }}
159-
// expected-note@+1 {{add 'async' to function 'testMethod()' to make it asynchronous}} {{38-38= async}}
160152
@OtherGlobalActor func testMethod() {
161-
method() // expected-error{{'async' in a function that does not support concurrency}}
153+
method() // expected-error{{instance method 'method()' isolated to global actor 'GenericGlobalActor<[T]>' can not be referenced from different global actor 'OtherGlobalActor'}}
162154
_ = method // expected-error{{instance method 'method()' isolated to global actor 'GenericGlobalActor<[T]>' can not be referenced from different global actor 'OtherGlobalActor'}}
163155
}
164156
}
@@ -231,9 +223,7 @@ func bar() async {
231223
foo() // expected-error{{call is 'async' but is not marked with 'await'}}
232224
}
233225

234-
// expected-note@+3 {{add '@SomeGlobalActor' to make global function 'barSync()' part of global actor 'SomeGlobalActor'}} {{1-1=@SomeGlobalActor }}
235-
// expected-note@+2 {{add '@asyncHandler' to function 'barSync()' to create an implicit asynchronous context}} {{1-1=@asyncHandler }}
236-
// expected-note@+1 {{add 'async' to function 'barSync()' to make it asynchronous}} {{15-15= async}}
226+
// expected-note@+1 {{add '@SomeGlobalActor' to make global function 'barSync()' part of global actor 'SomeGlobalActor'}} {{1-1=@SomeGlobalActor }}
237227
func barSync() {
238-
foo() // expected-error {{'async' in a function that does not support concurrency}}
228+
foo() // expected-error {{global function 'foo()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
239229
}

0 commit comments

Comments
 (0)