Skip to content

[concurrency] Cleanup verify-additional-prefix usage in tests. #83647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions test/Concurrency/actor_inout_isolation.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -verify-additional-prefix minimal-
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -verify-additional-prefix targeted-complete-tns- -verify-additional-prefix complete-tns- -strict-concurrency=complete
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -verify-additional-prefix complete- -strict-concurrency=complete

// REQUIRES: concurrency
// REQUIRES: asserts
Expand Down Expand Up @@ -100,7 +100,7 @@ extension TestActor {
// external class method call
@available(SwiftStdlib 5.1, *)
class NonAsyncClass {
// expected-targeted-complete-tns-note @-1 {{class 'NonAsyncClass' does not conform to the 'Sendable' protocol}}
// expected-complete-note @-1 {{class 'NonAsyncClass' does not conform to the 'Sendable' protocol}}
// expected-tns-note @-2 {{class 'NonAsyncClass' does not conform to the 'Sendable' protocol}}
func modifyOtherAsync(_ other : inout Int) async {
// ...
Expand All @@ -119,7 +119,7 @@ extension TestActor {
func passStateIntoDifferentClassMethod() async {
let other = NonAsyncClass()
let otherCurry = other.modifyOtherAsync
// expected-targeted-complete-tns-warning @-1 {{non-Sendable type 'NonAsyncClass' cannot exit actor-isolated context in call to nonisolated instance method 'modifyOtherAsync'}}
// expected-complete-warning @-1 {{non-Sendable type 'NonAsyncClass' cannot exit actor-isolated context in call to nonisolated instance method 'modifyOtherAsync'}}
await other.modifyOtherAsync(&value2)
// expected-error @-1 {{actor-isolated property 'value2' cannot be passed 'inout' to 'async' function call}}

Expand Down Expand Up @@ -212,22 +212,22 @@ struct MyGlobalActor {
// expected-note @-1 {{var declared here}}
// expected-note @-2 {{var declared here}}
// expected-note @-3 {{mutation of this var is only permitted within the actor}}
// expected-complete-tns-error @-4 {{top-level code variables cannot have a global actor}}
// expected-complete-tns-note @-5 4{{mutation of this var is only permitted within the actor}}
// expected-complete-error @-4 {{top-level code variables cannot have a global actor}}
// expected-complete-note @-5 4{{mutation of this var is only permitted within the actor}}


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

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


// It's okay to pass actor state inout to synchronous functions!
Expand All @@ -237,13 +237,13 @@ func globalSyncFunction(_ foo: inout Int) { }
@MyGlobalActor func globalActorSyncFunction(_ foo: inout Int) { }
@available(SwiftStdlib 5.1, *)
@MyGlobalActor func globalActorAsyncOkay() async { globalActorSyncFunction(&number) }
// expected-complete-tns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
// expected-complete-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
@available(SwiftStdlib 5.1, *)
@MyGlobalActor func globalActorAsyncOkay2() async { globalSyncFunction(&number) }
// expected-complete-tns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
// expected-complete-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
@available(SwiftStdlib 5.1, *)
@MyGlobalActor func globalActorSyncOkay() { globalSyncFunction(&number) }
// expected-complete-tns-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}
// expected-complete-error @-1 {{main actor-isolated var 'number' can not be used 'inout' from global actor 'MyGlobalActor'}}

// Gently unwrap things that are fine
@available(SwiftStdlib 5.1, *)
Expand Down Expand Up @@ -288,11 +288,11 @@ actor ProtectArray {
func test() async {
// FIXME: this is invalid too!
_ = await array.mutateAsynchronously
// expected-targeted-complete-tns-warning@-1 {{non-Sendable type '@lvalue [Int]' cannot exit actor-isolated context in call to nonisolated property 'mutateAsynchronously'}}
// expected-complete-warning@-1 {{non-Sendable type '@lvalue [Int]' cannot exit actor-isolated context in call to nonisolated property 'mutateAsynchronously'}}

_ = await array[mutateAsynchronously: 0]
// expected-error@-1 {{actor-isolated property 'array' cannot be passed 'inout' to 'async' function call}}
// expected-targeted-complete-tns-warning@-2 {{non-Sendable type 'inout Array<Int>' cannot exit actor-isolated context in call to nonisolated subscript 'subscript(mutateAsynchronously:)'}}
// expected-complete-warning@-2 {{non-Sendable type 'inout Array<Int>' cannot exit actor-isolated context in call to nonisolated subscript 'subscript(mutateAsynchronously:)'}}

await passToAsync(array[0])

Expand Down
18 changes: 9 additions & 9 deletions test/Concurrency/actor_isolation_unsafe.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -verify-additional-prefix complete-tns- -strict-concurrency=complete
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -verify-additional-prefix complete- -strict-concurrency=complete

// REQUIRES: concurrency

Expand All @@ -14,7 +14,7 @@ actor SomeGlobalActor {

// expected-warning@+1 {{'(unsafe)' global actors are deprecated; use '@preconcurrency' instead}}
@SomeGlobalActor(unsafe) func globalSome() { } // expected-note 2{{calls to global function 'globalSome()' from outside of its actor context are implicitly asynchronous}}
// expected-complete-tns-note @-1 {{calls to global function 'globalSome()' from outside of its actor context are implicitly asynchronous}}
// expected-complete-note @-1 {{calls to global function 'globalSome()' from outside of its actor context are implicitly asynchronous}}

// ----------------------------------------------------------------------
// Witnessing and unsafe global actor
Expand Down Expand Up @@ -56,15 +56,15 @@ struct S4_P1: P1 {
@MainActor(unsafe)
protocol P2 {
func f() // expected-note{{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
// expected-complete-tns-note @-1 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
// expected-complete-note @-1 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
nonisolated func g()
}

struct S5_P2: P2 {
func f() { } // expected-note{{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
// expected-note@-1 {{main actor isolation inferred from conformance to protocol 'P2'}}
// expected-complete-tns-note @-2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
// expected-complete-tns-note @-3 {{main actor isolation inferred from conformance to protocol 'P2'}}}
// expected-complete-note @-2 {{calls to instance method 'f()' from outside of its actor context are implicitly asynchronous}}
// expected-complete-note @-3 {{main actor isolation inferred from conformance to protocol 'P2'}}}
func g() { }
}

Expand All @@ -76,12 +76,12 @@ nonisolated func testP2(x: S5_P2, p2: P2) {
}

func testP2_noconcurrency(x: S5_P2, p2: P2) {
// expected-complete-tns-note @-1 2{{add '@MainActor' to make global function 'testP2_noconcurrency(x:p2:)' part of global actor 'MainActor'}}
// expected-complete-note @-1 2{{add '@MainActor' to make global function 'testP2_noconcurrency(x:p2:)' part of global actor 'MainActor'}}
p2.f() // okay without complete. with targeted/minimal not concurrency-related code.
// expected-complete-tns-warning @-1 {{call to main actor-isolated instance method 'f()' in a synchronous nonisolated context}}
// expected-complete-warning @-1 {{call to main actor-isolated instance method 'f()' in a synchronous nonisolated context}}
p2.g() // okay
x.f() // okay without complete. with targeted/minimal not concurrency-related code
// expected-complete-tns-warning @-1 {{call to main actor-isolated instance method 'f()' in a synchronous nonisolated context}}
// expected-complete-warning @-1 {{call to main actor-isolated instance method 'f()' in a synchronous nonisolated context}}
x.g() // OKAY
}

Expand All @@ -96,7 +96,7 @@ class C1 {
class C2: C1 {
override func method() { // expected-note 2{{overridden declaration is here}}
globalSome() // okay when not in complete
// expected-complete-tns-warning @-1 {{call to global actor 'SomeGlobalActor'-isolated global function 'globalSome()' in a synchronous main actor-isolated context}}
// expected-complete-warning @-1 {{call to global actor 'SomeGlobalActor'-isolated global function 'globalSome()' in a synchronous main actor-isolated context}}
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/Concurrency/async_initializer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %target-swift-frontend -enable-experimental-concurrency -target %target-swift-5.1-abi-triple -emit-sil -o /dev/null -verify %s
// RUN: %target-swift-frontend -enable-experimental-concurrency -target %target-swift-5.1-abi-triple -emit-sil -o /dev/null -verify -strict-concurrency=targeted %s
// RUN: %target-swift-frontend -enable-experimental-concurrency -target %target-swift-5.1-abi-triple -emit-sil -o /dev/null -verify -strict-concurrency=complete %s -verify-additional-prefix complete-and-tns-
// RUN: %target-swift-frontend -enable-experimental-concurrency -target %target-swift-5.1-abi-triple -emit-sil -o /dev/null -verify -strict-concurrency=complete %s -verify-additional-prefix complete-

// REQUIRES: concurrency

Expand Down Expand Up @@ -115,11 +115,11 @@ struct SomeStruct {
@MainActor(unsafe) init(asyncMainActorUnsafe: Int) async {}

// expected-warning@+2 {{'(unsafe)' global actors are deprecated; use '@preconcurrency' instead}}
// expected-complete-and-tns-note@+1 {{calls to initializer 'init(mainActorUnsafe:)' from outside of its actor context are implicitly asynchronous}}
// expected-complete-note@+1 {{calls to initializer 'init(mainActorUnsafe:)' from outside of its actor context are implicitly asynchronous}}
@MainActor(unsafe) init(mainActorUnsafe: Int) {}
}

// expected-complete-and-tns-note @+3 {{add '@MainActor' to make global function 'globActorTest1()' part of global actor 'MainActor'}}
// expected-complete-note @+3 {{add '@MainActor' to make global function 'globActorTest1()' part of global actor 'MainActor'}}
// expected-note @+2 {{add '@MainActor' to make global function 'globActorTest1()' part of global actor 'MainActor'}}
// expected-note @+1 2 {{add 'async' to function 'globActorTest1()' to make it asynchronous}}
func globActorTest1() {
Expand All @@ -129,7 +129,7 @@ func globActorTest1() {

_ = SomeStruct(asyncMainActorUnsafe: 0) // expected-error {{'async' call in a function that does not support concurrency}}

_ = SomeStruct(mainActorUnsafe: 0) // expected-complete-and-tns-warning {{call to main actor-isolated initializer 'init(mainActorUnsafe:)' in a synchronous nonisolated context}}
_ = SomeStruct(mainActorUnsafe: 0) // expected-complete-warning {{call to main actor-isolated initializer 'init(mainActorUnsafe:)' in a synchronous nonisolated context}}
}

func globActorTestAsyncEdition() async {
Expand Down
2 changes: 1 addition & 1 deletion test/Concurrency/async_let_isolation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted -verify-additional-prefix without-transferring-

// Then strict-concurrency with everything.
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -verify-additional-prefix tns-
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=complete

// REQUIRES: concurrency
// REQUIRES: asserts
Expand Down
2 changes: 1 addition & 1 deletion test/Concurrency/async_task_groups.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=targeted
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=complete -verify-additional-prefix tns-
// RUN: %target-swift-frontend -target %target-swift-5.1-abi-triple %s -emit-sil -o /dev/null -verify -strict-concurrency=complete

// REQUIRES: concurrency
// REQUIRES: asserts
Expand Down
10 changes: 5 additions & 5 deletions test/Concurrency/async_tasks.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %target-swift-frontend -strict-concurrency=targeted -target %target-swift-5.1-abi-triple %s -o /dev/null -verify -emit-sil -DALLOW_TYPECHECKER_ERRORS -verify-additional-prefix typechecker-
// RUN: %target-swift-frontend -strict-concurrency=complete -target %target-swift-5.1-abi-triple %s -o /dev/null -verify -emit-sil -DALLOW_TYPECHECKER_ERRORS -verify-additional-prefix typechecker-
// RUN: %target-swift-frontend -strict-concurrency=complete -target %target-swift-5.1-abi-triple %s -o /dev/null -verify -emit-sil -verify-additional-prefix tns-
// RUN: %target-swift-frontend -strict-concurrency=complete -target %target-swift-5.1-abi-triple %s -o /dev/null -verify -emit-sil -verify-additional-prefix complete-

// REQUIRES: concurrency
// REQUIRES: asserts
Expand Down Expand Up @@ -140,9 +140,9 @@ func test_detached_throwing() async -> String {

// ==== Detached Tasks with inout Params---------------------------------------
@available(SwiftStdlib 5.1, *)
func printOrderNumber(n: inout Int) async { // expected-tns-note {{parameter 'n' is declared 'inout'}}
Task.detached { // expected-tns-error {{escaping closure captures 'inout' parameter 'n'}}
n+=1 // expected-tns-note {{captured here}}
print(n) // expected-tns-note {{captured here}}
func printOrderNumber(n: inout Int) async { // expected-complete-note {{parameter 'n' is declared 'inout'}}
Task.detached { // expected-complete-error {{escaping closure captures 'inout' parameter 'n'}}
n+=1 // expected-complete-note {{captured here}}
print(n) // expected-complete-note {{captured here}}
}
}
Loading