Files
swift-mirror/test/Concurrency/async_sequence_existential.swift
Hamish Knight df187348bc [test] Add some extra for loop tests
Add some test cases that were uncovered when doing source compatibility
testing for the for loop rework.
2026-01-18 23:25:52 +00:00

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() {}
}