Files
swift-mirror/validation-test/compiler_crashers_2_fixed/rdar70144083.swift
Karoy Lorentey 47956908b7 [Concurrency] SwiftStdlib 5.5 ⟹ SwiftStdlib 5.1 (usages)
The concurrency runtime now deploys back to macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, which corresponds to the 5.1 release of the stdlib.

Adjust macro usages accordingly.
2021-10-28 14:36:36 -07: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)
}
}