Files
swift-mirror/validation-test/compiler_crashers_fixed/rdar70144083.swift
Hamish Knight 4e811c3a88 [test] Merge crasher directories
There is no longer much of a good reason to keep these separate,
merge them.
2025-10-18 12:51:30 +01:00

43 lines
1.1 KiB
Swift

// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-concurrency
// REQUIRES: concurrency
@available(SwiftStdlib 5.1, *)
public protocol AsyncIteratorProtocol {
associatedtype Element
associatedtype Failure: Error
mutating func nextResult() async -> Result<Element, Failure>?
mutating func cancel()
}
@available(SwiftStdlib 5.1, *)
public protocol AsyncSequence {
associatedtype Element
associatedtype Failure: Error
associatedtype AsyncIterator: AsyncIteratorProtocol where AsyncIterator.Element == Element, AsyncIterator.Failure == Failure
func makeAsyncIterator() -> AsyncIterator
}
@available(SwiftStdlib 5.1, *)
struct Just<Element>: AsyncSequence {
typealias Failure = Never
struct AsyncIterator: AsyncIteratorProtocol {
var value: Element?
mutating func nextResult() async -> Result<Element, Never>? {
defer { value = nil }
return value.map { .success($0) }
}
mutating func cancel() {
value = nil
}
}
var value: Element
func makeAsyncIterator() -> AsyncIterator {
return AsyncIterator(value: value)
}
}