1- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_1 | %FileCheck %s -check-prefix=LOOP_1
2- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_2 > %t.loop2.txt
3- // RUN: %FileCheck %s -check-prefix=LOOP_2 < %t.loop2.txt
4- // RUN: %FileCheck %s -check-prefix=LOOP_2_NEGATIVE < %t.loop2.txt
5- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_3 | %FileCheck %s -check-prefix=LOOP_3
6- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_4 | %FileCheck %s -check-prefix=LOOP_4
7- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_5 | %FileCheck %s -check-prefix=LOOP_5
8- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_6 | %FileCheck %s -check-prefix=LOOP_6
9- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_7 | %FileCheck %s -check-prefix=LOOP_6
10- // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=LOOP_8 | %FileCheck %s -check-prefix=LOOP_8
1+ // FIXME: Fails with non-source-ordering
2+ // RUN: %batch-code-completion -source-order-completion
113
124class Gen {
13- func IntGen( ) -> Int { return 0 }
14- func IntOpGen( ) -> Int ? { return 0 }
15- func IntSeqGen( ) -> [ Int ] { return [ 0 ] }
5+ func IntGen( ) -> Int { return 0 }
6+ func IntOpGen( ) -> Int ? { return 0 }
7+ func IntSeqGen( ) -> [ Int ] { return [ 0 ] }
168}
179
1810class C {
1911
20- func f1( _ Seq : [ Int ] , I : Int , G : Gen ) {
21- for i in #^LOOP_1 ^#
22- }
23- // LOOP_1-DAG: Decl[LocalVar]/Local/TypeRelation[Convertible]: Seq[#[Int]#]{{; name=.+$}}
24- // LOOP_1-DAG: Decl[LocalVar]/Local: I[#Int#]{{; name=.+$}}
25- // LOOP_1-DAG: Decl[LocalVar]/Local: G[#Gen#]{{; name=.+$}}
26- // LOOP_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: f1({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#]{{; name=.+$}}
27- // LOOP_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: f2({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#]{{; name=.+$}}
12+ func f1( _ Seq : [ Int ] , I : Int , G : Gen ) {
13+ for i in #^LOOP_1 ^#
14+ }
15+ // LOOP_1-DAG: Decl[LocalVar]/Local/TypeRelation[Convertible]: Seq[#[Int]#]{{; name=.+$}}
16+ // LOOP_1-DAG: Decl[LocalVar]/Local: I[#Int#]{{; name=.+$}}
17+ // LOOP_1-DAG: Decl[LocalVar]/Local: G[#Gen#]{{; name=.+$}}
18+ // LOOP_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: f1({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#]{{; name=.+$}}
19+ // LOOP_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: f2({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#]{{; name=.+$}}
2820
29- func f2( _ Seq : [ Int ] , I : Int , G: Gen ) {
30- for i in #^LOOP_2 ^# {
21+ func f2( _ Seq : [ Int ] , I : Int , G: Gen ) {
22+ for i in #^LOOP_2 ? check = LOOP_2 ; check = LOOP_2_NEGATIVE ^# {
3123
32- }
33- }
34- // LOOP_2-DAG: Decl[LocalVar]/Local/TypeRelation[Convertible]: Seq[#[Int]#]{{; name=.+$}}
35- // LOOP_2-DAG: Decl[LocalVar]/Local: I[#Int#]{{; name=.+$}}
36- // LOOP_2-DAG: Decl[LocalVar]/Local: G[#Gen#]{{; name=.+$}}
37- // LOOP_2-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: f1({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#]{{; name=.+$}}
38- // LOOP_2-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: f2({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#]{{; name=.+$}}
24+ }
25+ }
26+ // LOOP_2-DAG: Decl[LocalVar]/Local/TypeRelation[Convertible]: Seq[#[Int]#]{{; name=.+$}}
27+ // LOOP_2-DAG: Decl[LocalVar]/Local: I[#Int#]{{; name=.+$}}
28+ // LOOP_2-DAG: Decl[LocalVar]/Local: G[#Gen#]{{; name=.+$}}
29+ // LOOP_2-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: f1({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#]{{; name=.+$}}
30+ // LOOP_2-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: f2({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#]{{; name=.+$}}
3931
40- // LOOP_2_NEGATIVE-NOT: TypeRelation[{{.*}}]: SequenceType[#SequenceType#];
32+ // LOOP_2_NEGATIVE-NOT: TypeRelation[{{.*}}]: SequenceType[#SequenceType#];
4133
42- func f3( _ G : Gen ) {
43- for i in G. #^LOOP_3^#
44- }
34+ func f3( _ G : Gen ) {
35+ for i in G. #^LOOP_3^#
36+ }
4537
46- // LOOP_3-DAG: Decl[InstanceMethod]/CurrNominal: IntGen()[#Int#]{{; name=.+$}}
47- // LOOP_3-DAG: Decl[InstanceMethod]/CurrNominal: IntOpGen()[#Int?#]{{; name=.+$}}
48- // LOOP_3-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: IntSeqGen()[#[Int]#]{{; name=.+$}}
38+ // LOOP_3-DAG: Decl[InstanceMethod]/CurrNominal: IntGen()[#Int#]{{; name=.+$}}
39+ // LOOP_3-DAG: Decl[InstanceMethod]/CurrNominal: IntOpGen()[#Int?#]{{; name=.+$}}
40+ // LOOP_3-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: IntSeqGen()[#[Int]#]{{; name=.+$}}
4941
50- func f4( _ G : Gen ) {
51- for i in G. #^LOOP_4^# {
42+ func f4( _ G : Gen ) {
43+ for i in G. #^LOOP_4^# {
5244
53- }
54- }
45+ }
46+ }
5547
56- // LOOP_4-DAG: Decl[InstanceMethod]/CurrNominal: IntGen()[#Int#]{{; name=.+$}}
57- // LOOP_4-DAG: Decl[InstanceMethod]/CurrNominal: IntOpGen()[#Int?#]{{; name=.+$}}
58- // LOOP_4-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: IntSeqGen()[#[Int]#]{{; name=.+$}}
48+ // LOOP_4-DAG: Decl[InstanceMethod]/CurrNominal: IntGen()[#Int#]{{; name=.+$}}
49+ // LOOP_4-DAG: Decl[InstanceMethod]/CurrNominal: IntOpGen()[#Int?#]{{; name=.+$}}
50+ // LOOP_4-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: IntSeqGen()[#[Int]#]{{; name=.+$}}
5951
6052 func f5( _ a: [ C ] ) {
6153 do {
6254 for user in a {
6355 user. #^LOOP_5^#
64- // LOOP_5-DAG: Keyword[self]/CurrNominal: self[#C#];
65- // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f1({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#];
66- // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f2({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#];
67- // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f3({#(G): Gen#})[#Void#];
68- // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f4({#(G): Gen#})[#Void#];
69- // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f5({#(a): [C]#})[#Void#];
56+ // LOOP_5-DAG: Keyword[self]/CurrNominal: self[#C#];
57+ // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f1({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#];
58+ // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f2({#(Seq): [Int]#}, {#I: Int#}, {#G: Gen#})[#Void#];
59+ // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f3({#(G): Gen#})[#Void#];
60+ // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f4({#(G): Gen#})[#Void#];
61+ // LOOP_5-DAG: Decl[InstanceMethod]/CurrNominal: f5({#(a): [C]#})[#Void#];
7062 }
7163 } catch { }
7264 }
@@ -76,11 +68,13 @@ class C {
7668do {
7769 for value #^LOOP_6 ^#
7870}
71+ // LOOP_6: Begin completions, 1 items
72+ // LOOP_6-CHECK-NEXT: Keyword[in]/None: in; name=in
73+
7974do {
8075 for value #^LOOP_7 ^# 1 ..< 7 { }
8176}
82- // LOOP_6: Begin completions, 1 items
83- // LOOP_6-CHECK-NEXT: Keyword[in]/None: in; name=in
77+ // LOOP_7: Begin completions
8478
8579// Pack Iteration
8680do {
0 commit comments