|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t |
| 3 | + |
| 4 | +enum A { |
| 5 | + case one, two |
| 6 | +} |
| 7 | + |
| 8 | +struct B<T> { |
| 9 | + let value: T |
| 10 | + |
| 11 | + init(_ value: T) { |
| 12 | + self.value = value |
| 13 | + } |
| 14 | + |
| 15 | + static func void() -> B<Void> { |
| 16 | + return B<Void>(()) |
| 17 | + } |
| 18 | + |
| 19 | + static func data(_ data: Data) -> B<Data> { |
| 20 | + return B<Data>(data) |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +class C { |
| 25 | + func a(s: String = "", a: A) {} |
| 26 | + func b(s: String = "", i: Int = 0, a: A) {} |
| 27 | +} |
| 28 | + |
| 29 | +class D { |
| 30 | + func a<T>(b: B<T>, s: String = "") {} |
| 31 | + func b<T>(s: String = "", i: Int = 0, b: B<T>) {} |
| 32 | +} |
| 33 | + |
| 34 | +// type a point "." in placeholders to see the substitution list |
| 35 | + |
| 36 | +// correct substitution |
| 37 | +C().a(s: .#^STR_1?check=STRING^#, a: .#^A_1?check=A^#) |
| 38 | +C().a(a: .#^A_2?check=A^#) |
| 39 | + |
| 40 | +C().b(s: .#^STR_2?check=STRING^#, i: .#^INT_1?check=INT^#, a: .#^A_3?check=A^#) |
| 41 | +C().b(i: .#^INT_2?check=INT^#, a: .#^A_4?check=A^#) |
| 42 | +C().b(a: .#^A_5?check=A^#) |
| 43 | + |
| 44 | +D().a(b: .#^B_1?check=B^#, s: .#^STR_3?check=STRING^#) |
| 45 | +D().a(b: .#^B_2?check=B^#) |
| 46 | + |
| 47 | +D().b(s: .#^STR_4?check=STRING^#, i: .#^INT_3?check=INT^#, b: .#^B_3?check=B^#) |
| 48 | + |
| 49 | +// // incorrect substitution from previous parameter |
| 50 | +D().b(i: .#^INT_4?check=INT^#, b: .#^B_4?check=B^#) |
| 51 | +D().b(b: .#^B_5?check=B^#) |
| 52 | + |
| 53 | +// INT: Begin completions |
| 54 | +// INT-DAG: Decl[Constructor]/CurrNominal/IsSystem/TypeRelation[Convertible]: init({#bitPattern: UInt#})[#Int#]; name=init(bitPattern:) |
| 55 | +// INT: End completions |
| 56 | + |
| 57 | +// STRING: Begin completions |
| 58 | +// STRING-DAG: Decl[Constructor]/CurrNominal/IsSystem/TypeRelation[Convertible]: init()[#String#]; name=init() |
| 59 | +// STRING: End completions |
| 60 | + |
| 61 | +// A: Begin completions, 3 items |
| 62 | +// A-DAG: Decl[EnumElement]/CurrNominal/Flair[ExprSpecific]/TypeRelation[Convertible]: one[#A#]; name=one |
| 63 | +// A-DAG: Decl[EnumElement]/CurrNominal/Flair[ExprSpecific]/TypeRelation[Convertible]: two[#A#]; name=two |
| 64 | +// A-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: hash({#(self): A#})[#(into: inout Hasher) -> Void#]; name=hash(:) |
| 65 | +// A: End completions |
| 66 | + |
| 67 | +// B: Begin completions, 3 items |
| 68 | +// B-DAG: Decl[Constructor]/CurrNominal/TypeRelation[Convertible]: init({#(value): T#})[#B<T>#]; name=init(:) |
| 69 | +// B-DAG: Decl[StaticMethod]/CurrNominal/TypeRelation[Convertible]: void()[#B<Void>#]; name=void() |
| 70 | +// B-DAG: Decl[StaticMethod]/CurrNominal: data({#(data): <<error type>>#})[#<<error type>>#]; name=data(:) |
| 71 | +// B: End completions |
0 commit comments