mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +01:00
Add some test cases that were uncovered when doing source compatibility testing for the for loop rework.
33 lines
730 B
Swift
33 lines
730 B
Swift
// 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 -primary-file %s -dump-ast -o %t.ast.txt
|
|
// RUN: %FileCheck %s < %t.ast.txt
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
extension Error {
|
|
func printMe() { }
|
|
}
|
|
|
|
func test(seq: any AsyncSequence) async {
|
|
// CHECK-LABEL: (catch_stmts
|
|
// CHECK: (var_decl {{.*}} "error" interface_type="any Error"
|
|
do {
|
|
for try await _ in seq { }
|
|
} catch {
|
|
error.printMe()
|
|
}
|
|
}
|
|
|
|
protocol P {}
|
|
protocol Q: AsyncSequence where Self.Element: P {}
|
|
|
|
protocol R {
|
|
associatedtype X: Q
|
|
func bar() -> X
|
|
}
|
|
|
|
func foo(_ x: any R) async throws {
|
|
for try await _ in x.bar() {}
|
|
}
|