Skip to content

Commit 976c0b1

Browse files
committed
[CSSyntaticElement] Canonicalize type before collecting "in scope" variables
Follow-up to #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.
1 parent 6b3a17b commit 976c0b1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/Sema/CSSyntacticElement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class TypeVariableRefFinder : public ASTWalker {
217217
// For example `Typealias<$T, $U>.Context` which desugars into
218218
// `_Context<$U>` would bring in `$T` that could be inferrable
219219
// only after the body of the closure is solved.
220-
type = type->getDesugaredType();
220+
type = type->getCanonicalType();
221221

222222
// Don't walk into the opaque archetypes because they are not
223223
// transparent in this context - `some P` could reference a

validation-test/Sema/SwiftUI/rdar107835060.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct TestView<Data, Content: View> : View {
3232
typealias Context = Content._Context where Content: ContentProtocol
3333

3434
init<R, C>(_ data: Data,
35-
@ViewBuilder shelfContent: @escaping (Context) -> C)
35+
@ViewBuilder shelfContent: @escaping ([Context]) -> C)
3636
where Data.Element == any Model<R>,
3737
Content == ContinuousContent<LazyMapCollection<Data, AnyModel<R>>, C> {
3838
}
@@ -44,7 +44,7 @@ struct TestView<Data, Content: View> : View {
4444
func test(values: [any Model<[Int]>]) -> some View {
4545
TestView(values) { context in
4646
VStack {
47-
if context.offset == 0 {
47+
if context.first?.offset == 0 {
4848
}
4949
}
5050
}

0 commit comments

Comments
 (0)