Files
swift-mirror/validation-test/Concurrency/rdar107275872.swift
2024-05-01 20:57:20 -07:00

32 lines
775 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -O -Xfrontend -disable-availability-checking %s -plugin-path %swift-plugin-dir -parse-as-library -module-name main -o %t/main
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s
// REQUIRES: objc_interop
// REQUIRES: concurrency
// REQUIRES: executable_test
// REQUIRES: concurrency_runtime
// rdar://108260399
// REQUIRES: optimized_stdlib
import Foundation
@main struct M {
@TaskLocal static var v: UUID = UUID()
static func test(_ t: UUID) async {
await Self.$v.withValue(t) {
await Task.sleep(1)
print(Self.$v.get())
}
}
static func main() async {
// CHECK: before
print("before")
await test(UUID())
// CHECK: after
print("after")
}
}