Skip to content

Commit 21002f2

Browse files
committed
adjust tests
not even close to complete
1 parent c56f87a commit 21002f2

File tree

108 files changed

+270
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+270
-217
lines changed

test/Concurrency/Runtime/isolated_conformance.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ func tryCastToQ(_ value: any Sendable) -> Bool {
147147
// CHECK-NEXT: MyClass.f()
148148
// CHECK-NEXT: Wrapper for MyClass.f()
149149
print("Testing on the main actor")
150-
nonisolated let mc = MyClass()
151-
nonisolated let wrappedMC = Wrapper(wrapped: mc)
150+
let mc = MyClass()
151+
let wrappedMC = Wrapper(wrapped: mc)
152152
precondition(tryCastToP(mc))
153153
precondition(tryCastToP(wrappedMC))
154154

test/Concurrency/Runtime/isolated_deinit_main_sync.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// REQUIRES: concurrency_runtime
66
// UNSUPPORTED: back_deployment_runtime
77

8-
var isDead: Bool = false
8+
internal var isDead: Bool = false
99

1010
public class Foo {
1111
@MainActor

test/Concurrency/Runtime/startImmediately.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ print("\n\n==== ----------------------------------------------------------------
454454
print("call_taskImmediate_taskExecutor()")
455455

456456
@TaskLocal
457-
nonisolated(unsafe) var niceTaskLocalValueYouGotThere: String = ""
457+
nonisolated(unsafe) internal var niceTaskLocalValueYouGotThere: String = ""
458458

459459
// FIXME: rdar://155596073 Task executors execution may not always hop as expected
460460
func call_taskImmediate_taskExecutor(taskExecutor: NaiveQueueExecutor) async {

test/Concurrency/Runtime/startImmediately_order.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import _Concurrency
1616

17-
let max = 1000
17+
internal nonisolated let max = 1000
1818

1919
func bar(x: Int, cc: CheckedContinuation<Void, Never>) {
2020
Task.immediate {

test/Concurrency/actor_existentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func from_isolated_concrete(_ x: isolated A) async {
5151
actor Act {
5252
var i = 0 // expected-note {{mutation of this property is only permitted within the actor}}
5353
}
54-
nonisolated let act = Act()
54+
nonisolated internal let act = Act()
5555

5656
func bad() async {
5757
// expected-warning@+3 {{no 'async' operations occur within 'await' expression}}{{5-11=}}

test/Concurrency/actor_inout_isolation.swift

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,26 +208,25 @@ struct MyGlobalActor {
208208
static let shared = TestActor()
209209
}
210210

211-
@MyGlobalActor var number: Int = 0
212-
// expected-note @-1 {{var declared here}}
213-
// expected-note @-2 {{var declared here}}
214-
// expected-note @-3 {{mutation of this var is only permitted within the actor}}
215-
// expected-complete-error @-4 {{top-level code variables cannot have a global actor}}
216-
// expected-complete-note @-5 4{{mutation of this var is only permitted within the actor}}
211+
internal var number: Int = 0
212+
// expected-complete-note@-1 2{{var declared here}}
213+
// expected-complete-note@-2 {{mutation of this var is only permitted within the actor}}
214+
// expected-complete-note@-3 4{{mutation of this var is only permitted within the actor}}
217215

216+
@MyGlobalActor var anotherNumber: Int = 0
217+
// expected-error @-1 {{local variable 'anotherNumber' cannot have a global actor}}
218218

219219
if #available(SwiftStdlib 5.1, *) {
220220
let _ = Task.detached { await { (_ foo: inout Int) async in foo += 1 }(&number) }
221-
// expected-error @-1 {{actor-isolated var 'number' cannot be passed 'inout' to 'async' function call}}
222-
// expected-minimal-error @-2 {{global actor 'MyGlobalActor'-isolated var 'number' can not be used 'inout' from a nonisolated context}}
223-
// expected-complete-warning @-3 {{main actor-isolated var 'number' can not be used 'inout' from a nonisolated context}}
221+
// expected-complete-error@-1 {{actor-isolated var 'number' cannot be passed 'inout' to 'async' function call}}
222+
// expected-complete-warning@-2 {{main actor-isolated var 'number' can not be used 'inout' from a nonisolated context}}
224223
}
225224

226225
// attempt to pass global state owned by the global actor to another async function
227226
@available(SwiftStdlib 5.1, *)
228227
@MyGlobalActor func sneaky() async { await modifyAsynchronously(&number) }
229-
// expected-error @-1 {{actor-isolated var 'number' cannot be passed 'inout' to 'async' function call}}
230-
// expected-complete-error @-2 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
228+
// expected-complete-error@-1 {{actor-isolated var 'number' cannot be passed 'inout' to 'async' function call}}
229+
// expected-complete-error@-2 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
231230

232231

233232
// It's okay to pass actor state inout to synchronous functions!

test/Concurrency/assume_mainactor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class CustomActorIsolated {
256256
}
257257
}
258258

259-
var global = 0
259+
internal var global = 0
260260

261261
func onMain() async {
262262
await withTaskGroup { group in

test/Concurrency/freestanding_top_level.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// expected-complete-warning@+4 {{var 'global' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode}}
55
// expected-complete-note@+3 {{add '@MainActor' to make var 'global' part of global actor 'MainActor'}}{{1-1=@MainActor }}
66
// expected-complete-note@+2 {{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}{{1-1=nonisolated(unsafe) }}
7-
// expected-complete-note@+1 {{convert 'global' to a 'let' constant to make 'Sendable' shared state immutable}}{{1-4=let}}
8-
var global = 10
7+
// expected-complete-note@+1 {{convert 'global' to a 'let' constant to make 'Sendable' shared state immutable}}{{10-13=let}}
8+
internal var global = 10
99

1010
// No warning because we're in the same module.
1111
print(global)

test/Concurrency/global_actor_from_ordinary_context.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ func fromAsync() async {
130130
a[0] = 1 // expected-error{{global actor 'SomeGlobalActor'-isolated subscript 'subscript(_:)' can not be mutated from a nonisolated context}}
131131
}
132132

133-
// expected-minimal-and-targeted-note @+2 {{mutation of this var is only permitted within the actor}}
134-
// expected-complete-error @+1 {{top-level code variables cannot have a global actor}}
135-
@SomeGlobalActor var value: Int = 42
133+
@SomeGlobalActor internal var value: Int = 42
134+
// expected-note@-1 {{mutation of this var is only permitted within the actor}}
135+
136+
@SomeGlobalActor var anotherValue: Int = 42
137+
// expected-error@-1 {{local variable 'anotherValue' cannot have a global actor}}
136138

137139
func topLevelSyncFunction(_ number: inout Int) { }
138-
// expected-minimal-and-targeted-error @+1 {{global actor 'SomeGlobalActor'-isolated var 'value' can not be used 'inout' from a nonisolated context}}
139140
topLevelSyncFunction(&value)
141+
// expected-minimal-and-targeted-error@-1 {{global actor 'SomeGlobalActor'-isolated var 'value' can not be used 'inout' from a nonisolated context}}
142+
// expected-complete-warning@-2 {{global actor 'SomeGlobalActor'-isolated var 'value' can not be used 'inout' from the main actor}}
140143

141144
// Strict checking based on inferred Sendable/async/etc.
142145
@preconcurrency @SomeGlobalActor class Super { }

test/Concurrency/global_actor_inference.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,7 @@ func acceptAsyncSendableClosureInheriting<T>(@_inheritActorContext _: @Sendable
660660

661661
// defer bodies inherit global actor-ness
662662
@MainActor
663-
var statefulThingy: Bool = false // expected-minimal-targeted-note {{var declared here}}
664-
// expected-complete-error @-1 {{top-level code variables cannot have a global actor}}
663+
internal var statefulThingy: Bool = false // expected-minimal-targeted-note {{var declared here}}
665664

666665
@MainActor
667666
func useFooInADefer() -> String { // expected-minimal-targeted-note {{calls to global function 'useFooInADefer()' from outside of its actor context are implicitly asynchronous}}

0 commit comments

Comments
 (0)