mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for deployment to the minimum OS versions required for use of _Concurrency APIs, instead of disabling availability checking.
58 lines
1.0 KiB
Swift
58 lines
1.0 KiB
Swift
// RUN: %target-swift-frontend -enable-experimental-async-demotion -target %target-swift-5.1-abi-triple -module-name main -O -emit-sil -primary-file %s | %FileCheck %s --implicit-check-not hop_to_executor
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
// REQUIRES: concurrency
|
|
|
|
// for now, check for the expected number of hops after the pass:
|
|
|
|
// CHECK: hop_to_executor
|
|
// CHECK: hop_to_executor
|
|
// CHECK: hop_to_executor
|
|
// CHECK: hop_to_executor
|
|
|
|
@MainActor func mainActorFn() {}
|
|
|
|
func TRUE_LEAF() async {}
|
|
|
|
func ONE() async { await TWO() }
|
|
func TWO() async { await THREE() }
|
|
func THREE() async {
|
|
await TRUE_LEAF()
|
|
await ONE()
|
|
}
|
|
|
|
func NOT_CANDIDATE() async {
|
|
await mainActorFn()
|
|
await ONE()
|
|
}
|
|
|
|
@inline(never)
|
|
public
|
|
func fib(_ n: Int) async -> Int {
|
|
if n <= 1 { return n }
|
|
return await fib(n-1) + fib(n-2)
|
|
}
|
|
|
|
|
|
|
|
@inline(never)
|
|
@MainActor
|
|
public
|
|
func leaf() async {}
|
|
|
|
@MainActor
|
|
public
|
|
func start() async {
|
|
await leaf()
|
|
|
|
if await fib(40) != 102334155 {
|
|
fatalError("bug")
|
|
}
|
|
}
|
|
|
|
|
|
public
|
|
func checkIt(_ t: Task<Int, Never>) async -> Int {
|
|
await t.value
|
|
}
|