Files
swift-mirror/test/Concurrency/reasync_ranking.swift
Michael Gottesman 026f1735b5 [send-non-sendable] Update concurrency tests so that we run them in all concurrency modes as appropriate.
This means that:

1. In test cases where minimal is the default (swift 5 without
-warn-concurrency), I added RUN lines for targeted, complete, and complete +
sns.

2. In test cases where complete is the default (swift 6, -warn-concurrency,
specified complete with -strict-concurrency), I added a send non-sendable run
line.

In each of these cases, I added additional expected-* lines as appropriate so
the tests can compile in each mode successfully.
2023-08-30 13:40:17 -07:00

33 lines
1.1 KiB
Swift

// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency -disable-availability-checking
// REQUIRES: concurrency
// We don't want 'reasync' overloads to have a higher score in the
// case of a sync vs reasync mismatch the way 'async' overloads do,
// since this would change solver performance characteristics when
// using the reasync '&&', '||' and '??' operators.
func asyncOverload(_: () async -> (), _: Int) async {}
func asyncOverload(_: () -> (), _: String) {}
func referencesAsyncOverload() {
_ = asyncOverload // we prefer the sync overload
}
func referencesAsyncOverloadAsync() async {
_ = asyncOverload // we prefer the async overload
}
func reasyncOverload(_: () async -> (), _: Int) reasync {} // expected-note {{found this candidate}}
func reasyncOverload(_: () -> (), _: String) {} // expected-note {{found this candidate}}
func referencesReasyncOverload() {
_ = reasyncOverload // expected-error {{ambiguous use of 'reasyncOverload'}}
}
func referencesReasyncOverloadAsync() async {
// we prefer the async overload because the sync overload scores higher
// due to a sync-vs-async mismatch.
_ = reasyncOverload
}