Skip to content

Commit ae896ef

Browse files
committed
[Concurrency] Fix test failures that resulted from resolving merge conflicts
for 5.10 cherry picks.
1 parent 96d895f commit ae896ef

9 files changed

+28
-20
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
struct Foo {
2-
static let member = Bar()
2+
static let member = Bar() // expected-complete-warning {{static property 'member' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6}}
33
}

test/Concurrency/actor_inout_isolation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ actor TestActor {
4343
}
4444

4545
@available(SwiftStdlib 5.1, *)
46-
func modifyAsynchronously(_ foo: inout Int) async { foo += 1 }
46+
@Sendable func modifyAsynchronously(_ foo: inout Int) async { foo += 1 }
4747
@available(SwiftStdlib 5.1, *)
4848
enum Container {
4949
static let modifyAsyncValue = modifyAsynchronously
@@ -321,4 +321,4 @@ actor ProtectDictionary {
321321
// expected-warning@-1 {{cannot call mutating async function 'mutate()' on actor-isolated property 'dict'; this is an error in Swift 6}}
322322
// expected-targeted-complete-warning@-2 {{passing argument of non-sendable type 'inout Optional<Int>' outside of actor-isolated context may introduce data races}}
323323
}
324-
}
324+
}

test/Concurrency/actor_isolation.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import OtherActors // expected-remark{{add '@preconcurrency' to suppress 'Sendable'-related warnings from module 'OtherActors'}}{{1-1=@preconcurrency }}
1212

1313
let immutableGlobal: String = "hello"
14+
15+
// expected-warning@+2 {{var 'mutableGlobal' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in Swift 6}}
16+
// expected-note@+1 {{isolate 'mutableGlobal' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
1417
var mutableGlobal: String = "can't touch this" // expected-note 5{{var declared here}}
1518

1619
@available(SwiftStdlib 5.1, *)

test/Concurrency/concurrency_warnings.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ class GlobalCounter {
88
var counter: Int = 0
99
}
1010

11-
let rs = GlobalCounter()
12-
var globalInt = 17 // expected-note 2{{var declared here}}
11+
let rs = GlobalCounter() // expected-warning {{let 'rs' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6}}
12+
13+
var globalInt = 17 // expected-warning {{var 'globalInt' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in Swift 6}}
14+
// expected-note@-1 {{isolate 'globalInt' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
15+
// expected-note@-2 2{{var declared here}}
16+
1317

1418
class MyError: Error { // expected-warning{{non-final class 'MyError' cannot conform to 'Sendable'; use '@unchecked Sendable'}}
1519
var storage = 0 // expected-warning{{stored property 'storage' of 'Sendable'-conforming class 'MyError' is mutable}}

test/Concurrency/concurrent_value_checking.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ typealias CF = @Sendable () -> NotConcurrent?
271271
typealias BadGenericCF<T> = @Sendable () -> T?
272272
typealias GoodGenericCF<T: Sendable> = @Sendable () -> T? // okay
273273

274-
var concurrentFuncVar: (@Sendable (NotConcurrent) -> Void)? = nil
274+
var concurrentFuncVar: (@Sendable (NotConcurrent) -> Void)? = nil // expected-warning{{var 'concurrentFuncVar' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in Swift 6}}
275+
// expected-note@-1 {{isolate 'concurrentFuncVar' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
275276

276277
// ----------------------------------------------------------------------
277278
// Sendable restriction on @Sendable closures.

test/Concurrency/flow_isolation.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,9 @@ struct CardboardBox<T> {
518518

519519

520520
@available(SwiftStdlib 5.1, *)
521-
var globalVar: EscapeArtist? // expected-note 2 {{var declared here}}
521+
var globalVar: EscapeArtist? // expected-warning {{var 'globalVar' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in Swift 6}}
522+
// expected-note@-1 {{isolate 'globalVar' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
523+
// expected-note@-2 2 {{var declared here}}
522524

523525
@available(SwiftStdlib 5.1, *)
524526
actor EscapeArtist {

test/Concurrency/global_actor_inference.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/other_global_actor_inference.swiftmodule -module-name other_global_actor_inference -strict-concurrency=complete %S/Inputs/other_global_actor_inference.swift
44
// RUN: %target-swift-frontend -I %t -disable-availability-checking %s -emit-sil -o /dev/null -verify -verify-additional-prefix minimal-targeted-
55
// RUN: %target-swift-frontend -I %t -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted -verify-additional-prefix minimal-targeted-
6-
// RUN: %target-swift-frontend -I %t -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -verify-additional-prefix complete-tns-
7-
// RUN: %target-swift-frontend -I %t -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -enable-experimental-feature SendNonSendable -verify-additional-prefix complete-tns-
6+
// RUN: %target-swift-frontend -I %t -disable-availability-checking %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -verify-additional-prefix complete-sns-
87

98
// REQUIRES: concurrency
109
// REQUIRES: asserts
@@ -445,7 +444,7 @@ actor ActorWithWrapper {
445444
@WrapperOnActor var synced: Int = 0
446445
// expected-note@-1 3{{property declared here}}
447446
@WrapperWithMainActorDefaultInit var property: Int // expected-minimal-targeted-error {{call to main actor-isolated initializer 'init()' in a synchronous actor-isolated context}}
448-
// expected-complete-tns-error@-1 {{main actor-isolated default value in a actor-isolated context}}
447+
// expected-complete-sns-error@-1 {{main actor-isolated default value in a actor-isolated context}}
449448
func f() {
450449
_ = synced // expected-error{{main actor-isolated property 'synced' can not be referenced on a different actor instance}}
451450
_ = $synced // expected-error{{global actor 'SomeGlobalActor'-isolated property '$synced' can not be referenced on a different actor instance}}
@@ -561,7 +560,7 @@ struct WrapperOnUnsafeActor<Wrapped> {
561560

562561
// HasWrapperOnUnsafeActor gets an inferred @MainActor attribute.
563562
struct HasWrapperOnUnsafeActor {
564-
@WrapperOnUnsafeActor var synced: Int = 0 // expected-complete-tns-error {{global actor 'OtherGlobalActor'-isolated default value in a main actor-isolated context}}
563+
@WrapperOnUnsafeActor var synced: Int = 0 // expected-complete-sns-error {{global actor 'OtherGlobalActor'-isolated default value in a main actor-isolated context}}
565564
// expected-note @-1 3{{property declared here}}
566565
// expected-complete-sns-note @-2 3{{property declared here}}
567566

@@ -647,7 +646,7 @@ func acceptAsyncSendableClosureInheriting<T>(@_inheritActorContext _: @Sendable
647646
// defer bodies inherit global actor-ness
648647
@MainActor
649648
var statefulThingy: Bool = false // expected-minimal-targeted-note {{var declared here}}
650-
// expected-complete-tns-error @-1 {{top-level code variables cannot have a global actor}}
649+
// expected-complete-sns-error @-1 {{top-level code variables cannot have a global actor}}
651650

652651
@MainActor
653652
func useFooInADefer() -> String { // expected-minimal-targeted-note {{calls to global function 'useFooInADefer()' from outside of its actor context are implicitly asynchronous}}
@@ -681,10 +680,10 @@ class Cutter {
681680
@SomeGlobalActor
682681
class Butter {
683682
var a = useFooInADefer() // expected-minimal-targeted-error {{call to main actor-isolated global function 'useFooInADefer()' in a synchronous global actor 'SomeGlobalActor'-isolated context}}
684-
// expected-complete-tns-error@-1 {{main actor-isolated default value in a global actor 'SomeGlobalActor'-isolated context}}
683+
// expected-complete-sns-error@-1 {{main actor-isolated default value in a global actor 'SomeGlobalActor'-isolated context}}
685684

686685
nonisolated let b = statefulThingy // expected-minimal-targeted-error {{main actor-isolated var 'statefulThingy' can not be referenced from a non-isolated context}}
687-
// expected-complete-tns-error@-1 {{main actor-isolated default value in a nonisolated context}}
686+
// expected-complete-sns-error@-1 {{main actor-isolated default value in a nonisolated context}}
688687

689688
var c: Int = {
690689
return getGlobal7()

test/Concurrency/predates_concurrency.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func testElsewhere(x: X) {
8181
}
8282

8383
func testCalls(x: X) {
84-
// expected-complete-tns-note @-1 2{{add '@MainActor' to make global function 'testCalls(x:)' part of global actor 'MainActor'}}
84+
// expected-complete-sns-note @-1 2{{add '@MainActor' to make global function 'testCalls(x:)' part of global actor 'MainActor'}}
8585

8686
unsafelyMainActorClosure {
8787
onMainActor()
@@ -108,7 +108,7 @@ func testCalls(x: X) {
108108
let c = MyModelClass()
109109

110110
// okay with minimal/targeted... an error with complete.
111-
c.f() // expected-complete-tns-warning {{call to main actor-isolated instance method 'f()' in a synchronous nonisolated context}}
111+
c.f() // expected-complete-sns-error {{call to main actor-isolated instance method 'f()' in a synchronous nonisolated context}}
112112
}
113113

114114
func testCallsWithAsync() async {
@@ -117,10 +117,10 @@ func testCallsWithAsync() async {
117117

118118
let _: () -> Void = onMainActorAlways // expected-warning {{converting function value of type '@MainActor () -> ()' to '() -> Void' loses global actor 'MainActor'}}
119119

120-
let c = MyModelClass() // expected-minimal-targeted-warning{{expression is 'async' but is not marked with 'await'}}
120+
let c = MyModelClass() // expected-minimal-targeted-error{{expression is 'async' but is not marked with 'await'}}
121121
// expected-minimal-targeted-note@-1{{calls to initializer 'init()' from outside of its actor context are implicitly asynchronous}}
122122

123-
c.f() // expected-warning{{expression is 'async' but is not marked with 'await'}}
123+
c.f() // expected-error{{expression is 'async' but is not marked with 'await'}}
124124
// expected-note@-1{{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
125125
}
126126

test/Concurrency/sendable_cycle.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %target-swift-frontend %S/Inputs/sendable_cycle_other.swift -disable-availability-checking %s -verify -emit-sil -o /dev/null
22
// RUN: %target-swift-frontend %S/Inputs/sendable_cycle_other.swift -disable-availability-checking %s -verify -emit-sil -o /dev/null -strict-concurrency=targeted
3-
// RUN: %target-swift-frontend %S/Inputs/sendable_cycle_other.swift -disable-availability-checking %s -verify -emit-sil -o /dev/null -strict-concurrency=complete
4-
// RUN: %target-swift-frontend %S/Inputs/sendable_cycle_other.swift -disable-availability-checking %s -verify -emit-sil -o /dev/null -strict-concurrency=complete -enable-experimental-feature SendNonSendable
3+
// RUN: %target-swift-frontend %S/Inputs/sendable_cycle_other.swift -disable-availability-checking %s -verify -emit-sil -o /dev/null -strict-concurrency=complete -verify-additional-prefix complete-
54

65
// REQUIRES: concurrency
76
// REQUIRES: asserts

0 commit comments

Comments
 (0)