Files
swift-mirror/validation-test/Sema/SwiftUI/rdar107835060.swift
Pavel Yaskevich 976c0b17c3 [CSSyntaticElement] Canonicalize type before collecting "in scope" variables
Follow-up to https://github.com/apple/swift/pull/65048

`getDesugaredType` unwraps sugar types that appear in sequence,
to remove sugar from nested positions we need to get a canonical type.

Thanks to @slavapestov for pointing it out.
2023-04-11 11:53:31 -07:00

52 lines
1.2 KiB
Swift

// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5 -disable-availability-checking
// REQUIRES: objc_interop
// REQUIRES: OS=macosx
import SwiftUI
protocol Model<ReturnType> {
associatedtype ReturnType
}
struct AnyModel<ReturnType>: Model {
}
protocol ContentProtocol : View {
associatedtype _Context
}
struct CollectionContext<Data: RandomAccessCollection> {
let offset: Data.Index
}
struct ContinuousContent<Data: RandomAccessCollection, Content: View> : ContentProtocol
where Data.Element: Model, Data.Element.ReturnType: Sequence, Data.Index: Hashable {
typealias _Context = CollectionContext<Data>
var body: some View { EmptyView() }
}
struct TestView<Data, Content: View> : View {
typealias Context = Content._Context where Content: ContentProtocol
init<R, C>(_ data: Data,
@ViewBuilder shelfContent: @escaping ([Context]) -> C)
where Data.Element == any Model<R>,
Content == ContinuousContent<LazyMapCollection<Data, AnyModel<R>>, C> {
}
var body: some View { EmptyView() }
}
@ViewBuilder
func test(values: [any Model<[Int]>]) -> some View {
TestView(values) { context in
VStack {
if context.first?.offset == 0 {
}
}
}
}