Skip to content

Commit c0969f1

Browse files
authored
Merge pull request #38367 from ahoppen/pr/add-test-case-for-sr-14711
[CodeCompletion] Add test case for SR-14711
2 parents 75ca32e + 7525ebf commit c0969f1

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/IDE/complete_sr14711.swift

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %swift-ide-test --code-completion --source-filename %s --code-completion-token=COMPLETE | %FileCheck %s
2+
3+
struct TodaySectionEditView {
4+
var sections: [SectionHeaderView2] = []
5+
@ViewBuilder2 var body: some View2 {
6+
ForEach2(sections, id: \.text) { section in
7+
Text2("")
8+
Text2(section.text)
9+
.#^COMPLETE^#font()
10+
}
11+
}
12+
}
13+
14+
protocol View2 {}
15+
16+
extension View2 {
17+
func font() -> some View2 { fatalError() }
18+
}
19+
20+
@resultBuilder public struct ViewBuilder2 {
21+
static func buildBlock() -> Never { fatalError() }
22+
static func buildBlock<Content>(_ content: Content) -> Content where Content : View2 { fatalError() }
23+
static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> C0 where C0 : View2, C1 : View2 { fatalError() }
24+
}
25+
26+
struct Text2: View2 {
27+
init(_ s: String) {}
28+
}
29+
30+
struct SectionHeaderView2 {
31+
let text: String = ""
32+
}
33+
34+
public struct ForEach2<Data, ID, Content>: View2 where Data : RandomAccessCollection {
35+
init(_ data: Data, id: KeyPath<Data.Element, ID>, @ViewBuilder2 content: @escaping (Data.Element) -> Content) {}
36+
}
37+
38+
// CHECK: Begin completions, 2 items
39+
// CHECK-NEXT: Keyword[self]/CurrNominal: self[#Text2#];
40+
// CHECK-NEXT: Decl[InstanceMethod]/Super: font()[#View2#];
41+
// CHECK-NEXT: End completions

0 commit comments

Comments
 (0)