Files
swift-mirror/test/Generics/rdar124697829.swift
Slava Pestov 03467a1927 Add test case for rdar://124697829
This was fixed by 6cd5468cce.
2024-04-03 14:10:36 -04:00

42 lines
1.0 KiB
Swift

// RUN: %target-swift-frontend -emit-ir %s -disable-availability-checking
// This is a generics test, but only IRGen exercised the substitution of
// an abstract conformance with a type parameter -- in the type checker and
// SIL, we only deal with archetypes.
public protocol IteratorProtocol {
associatedtype Element
}
public protocol Sequence {
associatedtype Iterator: IteratorProtocol
associatedtype Element where Element == Iterator.Element
}
public struct IndexingIterator<S: Sequence>: IteratorProtocol {
public typealias Element = S.Element
}
public struct Array<Element>: Sequence {
public typealias Iterator = IndexingIterator<Self>
}
public protocol Publisher {
associatedtype Output
}
public struct SequencePublisher<Elements: Sequence>: Publisher {
public typealias Output = Elements.Element
}
public struct Map<Pub: Publisher, Output>: Publisher {}
public func foo<T>(_: T) -> some Publisher {
bar(SequencePublisher<Array<T>>())
}
public func bar<Pub: Publisher>(_: Pub) -> some Publisher {
Map<Pub, Pub.Output>()
}