Skip to content

Commit bab8500

Browse files
dan-zhengDave Abrahams
andauthored
Fix completion tests. (#33996)
Adding KeyPathIterable conformance to Optional changes the code completions for optional members. Co-authored-by: Dave Abrahams <[email protected]>
1 parent 74a17cd commit bab8500

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

test/IDE/complete_generic_optional.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct Foo<T> {
1111
// SR-642 Code completion does not instantiate generic arguments of a type wrapped in an optional
1212
let x: Foo<Bar>? = Foo<Bar>()
1313
x.#^FOO_OPTIONAL_1^#
14-
// FOO_OPTIONAL_1: Begin completions, 7 items
14+
// FOO_OPTIONAL_1: Begin completions, 13 items
1515
// FOO_OPTIONAL_1-DAG: Decl[InstanceMethod]/CurrNominal/Erase[1]: ?.myFunction({#(foobar): Bar#})[#Void#]; name=myFunction(foobar: Bar)
1616
// FOO_OPTIONAL_1-DAG: Keyword[self]/CurrNominal: self[#Foo<Bar>?#]; name=self
1717
// FOO_OPTIONAL_1: End completions

test/IDE/complete_stmt_controlling_expr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ func testGuardCase(x:FooStruct?) {
644644
// FOOSTRUCT_LOCALVAL-DAG: Decl[LocalVar]/Local{{(/TypeRelation\[Convertible\])?}}: boundVal[#FooStruct#];
645645
// FOOSTRUCT_LOCALVAL: End completions
646646

647-
// OPTIONAL_FOOSTRUCT: Begin completions, 9 items
647+
// OPTIONAL_FOOSTRUCT: Begin completions, 21 items
648648
// OPTIONAL_FOOSTRUCT-DAG: Keyword[nil]/None/Erase[1]: nil[#FooStruct?#]; name=nil
649649
// OPTIONAL_FOOSTRUCT-DAG: Decl[EnumElement]/CurrNominal/IsSystem: none[#Optional<FooStruct>#]; name=none
650650
// OPTIONAL_FOOSTRUCT-DAG: Decl[EnumElement]/CurrNominal/IsSystem: some({#FooStruct#})[#Optional<FooStruct>#]; name=some(FooStruct)

test/IDE/complete_swift_key_path_optional_root.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,40 @@ extension Optional {
1919
}
2020

2121
let _ : KeyPath<Person?, String> = \.#^TYPE_INFER_DOT_OPTIONAL^#
22-
// PERSONTYPE-INFER-DOT-OPT: Begin completions, 9 items
22+
// PERSONTYPE-INFER-DOT-OPT: Begin completions, 11 items
2323
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.name[#String#]; name=name
2424
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.friends[#[Person]#]; name=friends
2525
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.bestFriend[#Person?#]; name=bestFriend
2626
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.itself[#Person#]; name=itself
2727
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[Subscript]/CurrNominal: ?[{#(index): Int#}][#Int#]; name=[index: Int]
2828
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: unsafelyUnwrapped[#Person#]; name=unsafelyUnwrapped
2929
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: optMember[#String#]; name=optMember
30+
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: allKeyPaths[#[PartialKeyPath<Optional<Person>>]#]; name=allKeyPaths
3031
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: debugDescription[#String#]; name=debugDescription
3132
// PERSONTYPE-INFER-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: customMirror[#Mirror#]; name=customMirror
3233

3334
let _ : KeyPath<Person?, String> = \Person?.#^TYPE_DOT_OPTIONAL^#
34-
// PERSONTYPE-DOT-OPT: Begin completions, 9 items
35+
// PERSONTYPE-DOT-OPT: Begin completions, 11 items
3536
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.name[#String#]; name=name
3637
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.friends[#[Person]#]; name=friends
3738
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.bestFriend[#Person?#]; name=bestFriend
3839
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: ?.itself[#Person#]; name=itself
3940
// PERSONTYPE-DOT-OPT-NEXT: Decl[Subscript]/CurrNominal: ?[{#(index): Int#}][#Int#]; name=[index: Int]
4041
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: unsafelyUnwrapped[#Person#]; name=unsafelyUnwrapped
4142
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal: optMember[#String#]; name=optMember
43+
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: allKeyPaths[#[PartialKeyPath<Optional<Person>>]#]; name=allKeyPaths
4244
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: debugDescription[#String#]; name=debugDescription
4345
// PERSONTYPE-DOT-OPT-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: customMirror[#Mirror#]; name=customMirror
4446

4547
let _ : KeyPath<Person?, String> = \Person?. #^TYPE_DOT_OPTIONAL_SPACE^#
46-
// PERSONTYPE-DOT-OPT-SPACE: Begin completions, 9 items
48+
// PERSONTYPE-DOT-OPT-SPACE: Begin completions, 11 items
4749
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal/Erase[1]: ?.name[#String#]; name=name
4850
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal/Erase[1]: ?.friends[#[Person]#]; name=friends
4951
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal/Erase[1]: ?.bestFriend[#Person?#]; name=bestFriend
5052
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal/Erase[1]: ?.itself[#Person#]; name=itself
5153
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[Subscript]/CurrNominal/Erase[1]: ?[{#(index): Int#}][#Int#]; name=[index: Int]
5254
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: unsafelyUnwrapped[#Person#]; name=unsafelyUnwrapped
5355
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal: optMember[#String#]; name=optMember
56+
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: allKeyPaths[#[PartialKeyPath<Optional<Person>>]#]; name=allKeyPaths
5457
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: debugDescription[#String#]; name=debugDescription
5558
// PERSONTYPE-DOT-OPT-SPACE-NEXT: Decl[InstanceVar]/CurrNominal/IsSystem: customMirror[#Mirror#]; name=customMirror

test/IDE/complete_unresolved_members.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class C4 {
294294
// UNRESOLVED_3_NOTIDEAL-NOT: none
295295
// UNRESOLVED_3_NOTIDEAL-NOT: some(
296296

297-
// UNRESOLVED_3_OPT: Begin completions, 9 items
297+
// UNRESOLVED_3_OPT: Begin completions, 21 items
298298
// UNRESOLVED_3_OPT-DAG: Decl[EnumElement]/ExprSpecific/TypeRelation[Convertible]: North[#SomeEnum1#];
299299
// UNRESOLVED_3_OPT-DAG: Decl[EnumElement]/ExprSpecific/TypeRelation[Convertible]: South[#SomeEnum1#];
300300
// UNRESOLVED_3_OPT-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: hash({#(self): SomeEnum1#})[#(into: inout Hasher) -> Void#];
@@ -307,7 +307,7 @@ class C4 {
307307
// UNRESOLVED_3_OPT-NOT: init({#nilLiteral:
308308
// UNRESOLVED_3_OPT-DAG: Decl[InstanceMethod]/CurrNominal/IsSystem/TypeRelation[Invalid]: hash({#(self): Optional<SomeEnum1>#})[#(into: inout Hasher) -> Void#];
309309

310-
// UNRESOLVED_3_OPTOPTOPT: Begin completions, 9 items
310+
// UNRESOLVED_3_OPTOPTOPT: Begin completions, 21 items
311311
// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[EnumElement]/ExprSpecific/TypeRelation[Convertible]: North[#SomeEnum1#];
312312
// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[EnumElement]/ExprSpecific/TypeRelation[Convertible]: South[#SomeEnum1#];
313313
// UNRESOLVED_3_OPTOPTOPT-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: hash({#(self): SomeEnum1#})[#(into: inout Hasher) -> Void#];
@@ -329,7 +329,7 @@ extension Optional where Wrapped == Somewhere {
329329
}
330330
func testOptionalWithCustomExtension() {
331331
var _: Somewhere? = .#^UNRESOLVED_OPT_4^#
332-
// UNRESOLVED_OPT_4: Begin completions, 11 items
332+
// UNRESOLVED_OPT_4: Begin completions, 23 items
333333
// UNRESOLVED_OPT_4-DAG: Decl[EnumElement]/ExprSpecific/TypeRelation[Convertible]: earth[#Somewhere#];
334334
// UNRESOLVED_OPT_4-DAG: Decl[EnumElement]/ExprSpecific/TypeRelation[Convertible]: mars[#Somewhere#];
335335
// UNRESOLVED_OPT_4-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: hash({#(self): Somewhere#})[#(into: inout Hasher) -> Void#];

0 commit comments

Comments
 (0)