Skip to content

Commit 3f1a6c8

Browse files
committed
Update tests for isolated conformances being enabled by default
1 parent 3380331 commit 3f1a6c8

8 files changed

+17
-7
lines changed

test/Concurrency/concurrent_value_checking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ var concurrentFuncVar: (@Sendable (NotConcurrent) -> Void)? = nil // expected-wa
305305
// ----------------------------------------------------------------------
306306
func acceptConcurrentUnary<T>(_: @Sendable (T) -> T) { }
307307

308-
func concurrentClosures<T>(_: T) { // expected-note{{consider making generic parameter 'T' conform to the 'Sendable' protocol}} {{26-26=: Sendable}}
308+
func concurrentClosures<T: SendableMetatype>(_: T) { // expected-note{{consider making generic parameter 'T' conform to the 'Sendable' protocol}} {{44-44= & Sendable}}
309309
acceptConcurrentUnary { (x: T) in
310310
_ = x // ok
311311
acceptConcurrentUnary { _ in x } // expected-warning{{capture of 'x' with non-sendable type 'T' in a '@Sendable' closure}}

test/Concurrency/global_actor_inference.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ protocol Interface {
127127
@MainActor
128128
class Object: Interface {
129129
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}{{15-15=@preconcurrency }}
130+
// expected-note@-2{{isolate this conformance to the main actor with '@MainActor'}}
130131

131132
var baz: Int = 42 // expected-note{{main actor-isolated property 'baz' cannot satisfy nonisolated requirement}}
132133
}

test/Concurrency/global_actor_inference_swift6.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ protocol InferenceConflictWithSuperclass: MainActorSuperclass, InferSomeGlobalAc
207207
class C2: MainActorSuperclass, InferenceConflictWithSuperclass {
208208
//expected-note@-1 {{turn data races into runtime errors with '@preconcurrency'}}
209209
// expected-note@-2{{mark all declarations used in the conformance 'nonisolated'}}
210+
// expected-note@-3{{isolate this conformance to the main actor with '@MainActor'}}
210211

211212
func f() {}
212213

test/Concurrency/isolated_conformance_inference.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-swift-frontend -typecheck -verify -target %target-swift-5.1-abi-triple -swift-version 6 -enable-upcoming-feature InferIsolatedConformances %s
22

33
// REQUIRES: concurrency
4+
// REQUIRES: swift_feature_InferIsolatedConformances
45

56
protocol P {
67
func f()

test/Concurrency/preconcurrency_conformances.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ final class K : @preconcurrency Initializable {
108108
final class MainActorK: Initializable {
109109
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}{{25-25=@preconcurrency }}
110110
// expected-note@-2{{mark all declarations used in the conformance 'nonisolated'}}
111+
// expected-note@-3{{isolate this conformance to the main actor with '@MainActor'}}
111112
init() { } // expected-note{{main actor-isolated initializer 'init()' cannot satisfy nonisolated requirement}}
112113
}
113114

@@ -236,6 +237,7 @@ do {
236237
// expected-warning@-1:21 {{@preconcurrency attribute on conformance to 'P3' has no effect}}
237238
// expected-note@-2:45 {{turn data races into runtime errors with '@preconcurrency'}}
238239
// expected-note@-3{{mark all declarations used in the conformance 'nonisolated'}}
240+
// expected-note@-4{{isolate this conformance to the main actor with '@MainActor'}}
239241
func foo() {}
240242
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot satisfy nonisolated requirement}}
241243
}
@@ -244,6 +246,7 @@ do {
244246
// expected-warning@-1:21 {{@preconcurrency attribute on conformance to 'P3' has no effect}}
245247
// expected-note@-2:25 {{turn data races into runtime errors with '@preconcurrency'}}
246248
// expected-note@-3{{mark all declarations used in the conformance 'nonisolated'}}
249+
// expected-note@-4{{isolate this conformance to the main actor with '@MainActor'}}
247250
func foo() {}
248251
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot satisfy nonisolated requirement}}
249252
}
@@ -304,6 +307,7 @@ do {
304307
// expected-warning@-1:21 {{@preconcurrency attribute on conformance to 'P5' has no effect}}
305308
// expected-note@-2{{turn data races into runtime errors with '@preconcurrency'}}
306309
// expected-note@-3{{mark all declarations used in the conformance 'nonisolated'}}
310+
// expected-note@-4{{isolate this conformance to the main actor with '@MainActor'}}
307311
func foo() {}
308312
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot satisfy nonisolated requirement}}
309313
}

test/Concurrency/predates_concurrency.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ extension MainActorPreconcurrency: NotIsolated {
234234
// expected-complete-note@-1{{add '@preconcurrency' to the 'NotIsolated' conformance to suppress isolation-related diagnostics}}{{36-36=@preconcurrency }}
235235
// expected-complete-tns-note@-2{{turn data races into runtime errors with '@preconcurrency'}}{{36-36=@preconcurrency }}
236236
// expected-complete-tns-note@-3{{mark all declarations used in the conformance 'nonisolated'}}
237+
// expected-complete-tns-note@-4{{isolate this conformance to the main actor with '@MainActor'}}
237238
func requirement() {}
238239
// expected-complete-tns-note@-1 {{main actor-isolated instance method 'requirement()' cannot satisfy nonisolated requirement}}
239240
// expected-complete-tns-note@-2 {{calls to instance method 'requirement()' from outside of its actor context are implicitly asynchronous}}

test/Concurrency/transfernonsendable_nonisolatedunsafe.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,24 +307,24 @@ func useAfterTransferLetSquelchedIndirectAddressOnly<T : ProvidesStaticValue>(_
307307

308308
await transferToMainIndirect(ns)
309309
// expected-tns-warning @-1 {{sending 'ns' risks causing data races}}
310-
// expected-tns-note @-2 {{sending 'ns' to main actor-isolated global function 'transferToMainIndirect' risks causing data races between main actor-isolated and local nonisolated uses}}
310+
// expected-tns-note @-2 {{sending task-isolated 'ns' to main actor-isolated global function 'transferToMainIndirect' risks causing data races between main actor-isolated and task-isolated uses}}
311311
// expected-complete-warning @-3 {{passing argument of non-sendable type 'T' into main actor-isolated context may introduce data races}}
312-
print(ns) // expected-tns-note {{access can happen concurrently}}
312+
print(ns)
313313

314314
await transferToMainIndirect(ns2)
315315
print(ns2)
316316

317317
await transferToMainIndirect(ns3)
318318
// expected-tns-warning @-1 {{sending 'ns3' risks causing data races}}
319-
// expected-tns-note @-2 {{sending 'ns3' to main actor-isolated global function 'transferToMainIndirect' risks causing data races between main actor-isolated and local nonisolated uses}}
319+
// expected-tns-note @-2 {{sending task-isolated 'ns3' to main actor-isolated global function 'transferToMainIndirect' risks causing data races between main actor-isolated and task-isolated uses}}
320320
// expected-complete-warning @-3 {{passing argument of non-sendable type 'T' into main actor-isolated context may introduce data races}}
321-
print(ns3) // expected-tns-note {{access can happen concurrently}}
321+
print(ns3)
322322

323323
await transferToMainIndirect(ns4)
324324
// expected-tns-warning @-1 {{sending 'ns4' risks causing data races}}
325-
// expected-tns-note @-2 {{sending 'ns4' to main actor-isolated global function 'transferToMainIndirect' risks causing data races between main actor-isolated and local nonisolated uses}}
325+
// expected-tns-note @-2 {{sending task-isolated 'ns4' to main actor-isolated global function 'transferToMainIndirect' risks causing data races between main actor-isolated and task-isolated uses}}
326326
// expected-complete-warning @-3 {{passing argument of non-sendable type 'T' into main actor-isolated context may introduce data races}}
327-
print(ns4) // expected-tns-note {{access can happen concurrently}}
327+
print(ns4)
328328
}
329329

330330
////////////////////////

test/decl/class/actor/global_actor_conformance.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ protocol P2 {
3232
// expected-warning@+1{{conformance of 'C1' to protocol 'P1' crosses into global actor 'GlobalActor'-isolated code and can cause data races}}
3333
class C1 : P1, P2 {
3434
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}
35+
// expected-note@-2{{isolate this conformance to the global actor 'GlobalActor' with '@GlobalActor'}}
3536

3637
typealias Assoc = String
3738

@@ -57,6 +58,7 @@ protocol NonIsolatedRequirement {
5758
extension OnMain: NonIsolatedRequirement {
5859
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}
5960
// expected-note@-2{{mark all declarations used in the conformance 'nonisolated'}}
61+
// expected-note@-3{{isolate this conformance to the main actor with '@MainActor'}}
6062
// expected-note@+1 {{main actor-isolated instance method 'requirement()' cannot satisfy nonisolated requirement}}
6163
func requirement() {}
6264
}

0 commit comments

Comments
 (0)