120
120
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GUARD_LET_BIND_7 | %FileCheck %s -check-prefix=FOOSTRUCT_LOCALVAL
121
121
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GUARD_LET_BIND_8 | %FileCheck %s -check-prefix=FOOSTRUCT_LOCALVAL
122
122
123
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GUARD_CASE_PATTERN_1| %FileCheck %s -check-prefix=OPTIONAL_FOOSTRUCT
124
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GUARD_CASE_PATTERN_2| %FileCheck %s -check-prefix=OPTIONAL_FOOSTRUCT
125
+
123
126
struct FooStruct {
124
127
var instanceVar : Int
125
128
init ( _: Int = 0 ) { }
@@ -612,7 +615,12 @@ func testGuardLetBinding7(x: FooStruct?) {
612
615
func testGuardLetBinding8( _ x: FooStruct? ) {
613
616
guard let boundVal = x, let other = testGuardLetBinding8 ( #^GUARD_LET_BIND_8 ^#) else { }
614
617
}
615
-
618
+ func testGuardCase( x: FooStruct? ) {
619
+ guard case . #^GUARD_CASE_PATTERN_1^# = x { }
620
+ }
621
+ func testGuardCase( x: FooStruct? ) {
622
+ guard case . #^GUARD_CASE_PATTERN_2^#some( ) = x { }
623
+ }
616
624
617
625
// FOOSTRUCT_DOT: Begin completions
618
626
// FOOSTRUCT_DOT-DAG: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#];
@@ -635,3 +643,12 @@ func testGuardLetBinding8(_ x: FooStruct?) {
635
643
// FOOSTRUCT_LOCALVAL: Begin completions
636
644
// FOOSTRUCT_LOCALVAL-DAG: Decl[LocalVar]/Local{{(/TypeRelation\[Convertible\])?}}: boundVal[#FooStruct#];
637
645
// FOOSTRUCT_LOCALVAL: End completions
646
+
647
+ // OPTIONAL_FOOSTRUCT: Begin completions, 5 items
648
+ // OPTIONAL_FOOSTRUCT-DAG: Keyword[nil]/None/Erase[1]: nil[#FooStruct?#]; name=nil
649
+ // OPTIONAL_FOOSTRUCT-DAG: Decl[EnumElement]/CurrNominal/IsSystem: none[#Optional<FooStruct>#]; name=none
650
+ // OPTIONAL_FOOSTRUCT-DAG: Decl[EnumElement]/CurrNominal/IsSystem: some({#FooStruct#})[#Optional<FooStruct>#]; name=some(FooStruct)
651
+ // FIXME: 'FooStruct' members should not be shown.
652
+ // OPTIONAL_FOOSTRUCT-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: init()[#FooStruct#]; name=init()
653
+ // OPTIONAL_FOOSTRUCT-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: init({#Int#})[#FooStruct#]; name=init(Int)
654
+ // OPTIONAL_FOOSTRUCT: End completions
0 commit comments