Skip to content

Commit d781a94

Browse files
authored
Merge pull request #37310 from ahoppen/pr-5.5/wrapping-lvalue
[5.5][TypeChecker] Clear param specifiers before re-typechecking expression for completion
2 parents d0c9b6b + 5fd5574 commit d781a94

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

lib/Sema/TypeCheckCodeCompletion.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ class SanitizeExpr : public ASTWalker {
242242
if (auto closure = dyn_cast<ClosureExpr>(expr)) {
243243
if (!shouldTypeCheckInEnclosingExpression(closure))
244244
return { false, expr };
245+
for (auto &Param : *closure->getParameters()) {
246+
Param->setSpecifier(swift::ParamSpecifier::Default);
247+
}
245248
}
246249

247250
// Now, we're ready to walk into sub expressions.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename=%s | %FileCheck %s
2+
3+
protocol MyView {
4+
associatedtype Body : MyView
5+
@MyViewBuilder var body: Self.Body { get }
6+
}
7+
8+
@resultBuilder public struct MyViewBuilder {
9+
static func buildBlock() -> MyZStack<Never> { fatalError() }
10+
static func buildBlock<Content>(_ content: Content) -> Content { content }
11+
}
12+
13+
struct MyAlignment {
14+
static let center: MyAlignment
15+
}
16+
17+
struct MyZStack<Content> : MyView {
18+
init(alignment: MyAlignment, @MyViewBuilder content: () -> Content) {
19+
fatalError()
20+
}
21+
22+
func my_updating<State>(body: (inout State) -> Void) {}
23+
}
24+
25+
struct BottomMenu: MyView {
26+
var body: some MyView {
27+
let a = MyZStack(alignment: .#^COMPLETE^#center, content: {})
28+
.my_updating(body: { state in
29+
state = false
30+
})
31+
}
32+
}
33+
34+
// CHECK: Begin completions, 2 items
35+
// CHECK: Decl[StaticVar]/ExprSpecific/TypeRelation[Identical]: center[#MyAlignment#]; name=center
36+
// CHECK: Decl[Constructor]/CurrNominal/TypeRelation[Identical]: init()[#MyAlignment#]; name=init()
37+
// CHECK: End completions

0 commit comments

Comments
 (0)