|
| 1 | +// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5 -disable-availability-checking |
| 2 | + |
| 3 | +// REQUIRES: objc_interop |
| 4 | +// REQUIRES: OS=macosx |
| 5 | + |
| 6 | +import SwiftUI |
| 7 | + |
| 8 | +protocol Model<ReturnType> { |
| 9 | + associatedtype ReturnType |
| 10 | +} |
| 11 | + |
| 12 | +struct AnyModel<ReturnType>: Model { |
| 13 | +} |
| 14 | + |
| 15 | +protocol ContentProtocol : View { |
| 16 | + associatedtype _Context |
| 17 | +} |
| 18 | + |
| 19 | +struct CollectionContext<Data: RandomAccessCollection> { |
| 20 | + let offset: Data.Index |
| 21 | +} |
| 22 | + |
| 23 | +struct ContinuousContent<Data: RandomAccessCollection, Content: View> : ContentProtocol |
| 24 | + where Data.Element: Model, Data.Element.ReturnType: Sequence, Data.Index: Hashable { |
| 25 | + |
| 26 | + typealias _Context = CollectionContext<Data> |
| 27 | + |
| 28 | + var body: some View { EmptyView() } |
| 29 | +} |
| 30 | + |
| 31 | +struct TestView<Data, Content: View> : View { |
| 32 | + typealias Context = Content._Context where Content: ContentProtocol |
| 33 | + |
| 34 | + init<R, C>(_ data: Data, |
| 35 | + @ViewBuilder shelfContent: @escaping (Context) -> C) |
| 36 | + where Data.Element == any Model<R>, |
| 37 | + Content == ContinuousContent<LazyMapCollection<Data, AnyModel<R>>, C> { |
| 38 | + } |
| 39 | + |
| 40 | + var body: some View { EmptyView() } |
| 41 | +} |
| 42 | + |
| 43 | +@ViewBuilder |
| 44 | +func test(values: [any Model<[Int]>]) -> some View { |
| 45 | + TestView(values) { context in |
| 46 | + VStack { |
| 47 | + if context.offset == 0 { |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | +} |
0 commit comments