Skip to content

Commit 4c186c0

Browse files
committed
[CodeCompletion] Fix code completion issues related to type checking tap expressions in the cosntraint system
1 parent 6cec68e commit 4c186c0

File tree

5 files changed

+23
-28
lines changed

5 files changed

+23
-28
lines changed

lib/Sema/TypeCheckCodeCompletion.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,6 @@ bool TypeChecker::typeCheckForCodeCompletion(
586586
if (!contextAnalyzer.hasCompletion())
587587
return false;
588588

589-
// Interpolation components are type-checked separately.
590-
if (contextAnalyzer.locatedInStringInterpolation())
591-
return false;
592-
593-
// FIXME: There is currently no way to distinguish between
594-
// multi-statement closures which are result builder bodies
595-
// (that are type-checked together with enclosing context)
596-
// and regular closures which are type-checked separately.
597-
598589
if (needsPrecheck) {
599590
// First, pre-check the expression, validating any types that occur in the
600591
// expression and folding sequence expressions.

test/IDE/complete_in_result_builder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func testCompleteInStringLiteral() {
197197
}
198198
// STRING_LITERAL_VAR: Begin completions, 2 items
199199
// STRING_LITERAL_VAR-DAG: Keyword[self]/CurrNominal: self[#Island#]; name=self
200-
// STRING_LITERAL_VAR-DAG: Decl[InstanceVar]/CurrNominal/TypeRelation[Convertible]: turnipPrice[#String#]; name=turnipPrice
200+
// STRING_LITERAL_VAR-DAG: Decl[InstanceVar]/CurrNominal: turnipPrice[#String#]; name=turnipPrice
201201
}
202202

203203
func bar(island: Island) {

test/IDE/complete_rdar63965160.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token=STRINGLITERAL | %FileCheck %s
2-
// RUN: %swift-ide-test -code-completion -source-filename %s -code-completion-token=NORMAL | %FileCheck %s
1+
// RUN: %empty-directory(%t)
2+
// RUN: %swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
33

44
protocol View {}
55

@@ -32,6 +32,10 @@ func test(values: [Value]) {
3232
Text(value.#^NORMAL?check=CHECK^#)
3333
}
3434
}
35-
// CHECK: Begin completions, 2 items
36-
// CHECK-DAG: Keyword[self]/CurrNominal: self[#Value#];
37-
// CHECK-DAG: Decl[InstanceVar]/CurrNominal/TypeRelation[Convertible]: name[#String#];
35+
// STRINGLITERAL: Begin completions, 2 items
36+
// STRINGLITERAL-DAG: Keyword[self]/CurrNominal: self[#Value#];
37+
// STRINGLITERAL-DAG: Decl[InstanceVar]/CurrNominal: name[#String#];
38+
39+
// NORMAL: Begin completions, 2 items
40+
// NORMAL-DAG: Keyword[self]/CurrNominal: self[#Value#];
41+
// NORMAL-DAG: Decl[InstanceVar]/CurrNominal/TypeRelation[Convertible]: name[#String#];

test/IDE/complete_value_expr.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,18 +1103,18 @@ func testResolveModules1() {
11031103
//===--- Check that we can complete inside interpolated string literals
11041104

11051105
func testInterpolatedString1() {
1106-
"\(fooObject.#^INTERPOLATED_STRING_1?check=FOO_OBJECT_DOT1^#)"
1107-
}
1108-
1109-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceVar]/CurrNominal/TypeRelation[Convertible]: lazyInstanceVar[#Int#]{{; name=.+$}}
1110-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceVar]/CurrNominal/TypeRelation[Convertible]: instanceVar[#Int#]{{; name=.+$}}
1111-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc0()[#Void#]{{; name=.+$}}
1112-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc1({#(a): Int#})[#Void#]{{; name=.+$}}
1113-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc2({#(a): Int#}, {#b: &Double#})[#Void#]{{; name=.+$}}
1114-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc3({#(a): Int#}, {#(Float, Double)#})[#Void#]{{; name=.+$}}
1115-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc4({#(a): Int?#}, {#b: Int!#}, {#c: &Int?#}, {#d: &Int!#})[#Void#]{{; name=.+$}}
1116-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceMethod]/CurrNominal: instanceFunc5()[#Int?#]{{; name=.+$}}
1117-
// FOO_OBJECT_DOT1-DAG: Decl[InstanceMethod]/CurrNominal: instanceFunc6()[#Int!#]{{; name=.+$}}
1106+
"\(fooObject.#^INTERPOLATED_STRING_1^#)"
1107+
}
1108+
1109+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceVar]/CurrNominal: lazyInstanceVar[#Int#]{{; name=.+$}}
1110+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#]{{; name=.+$}}
1111+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc0()[#Void#]{{; name=.+$}}
1112+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc1({#(a): Int#})[#Void#]{{; name=.+$}}
1113+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc2({#(a): Int#}, {#b: &Double#})[#Void#]{{; name=.+$}}
1114+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc3({#(a): Int#}, {#(Float, Double)#})[#Void#]{{; name=.+$}}
1115+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: instanceFunc4({#(a): Int?#}, {#b: Int!#}, {#c: &Int?#}, {#d: &Int!#})[#Void#]{{; name=.+$}}
1116+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceMethod]/CurrNominal: instanceFunc5()[#Int?#]{{; name=.+$}}
1117+
// INTERPOLATED_STRING_1-DAG: Decl[InstanceMethod]/CurrNominal: instanceFunc6()[#Int!#]{{; name=.+$}}
11181118
11191119
//===--- Check protocol extensions
11201120

validation-test/IDE/stress_tester_issues_fixed/issue-57058.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ struct MysteryIslandDetail {
3232

3333
// CHECK: Begin completions, 2 items
3434
// CHECK-DAG: Keyword[self]/CurrNominal: self[#MysteryIsland2#]; name=self
35-
// CHECK-DAG: Decl[InstanceVar]/CurrNominal/TypeRelation[Convertible]: chance[#Int#]; name=chance
35+
// CHECK-DAG: Decl[InstanceVar]/CurrNominal: chance[#Int#]; name=chance

0 commit comments

Comments
 (0)