|
1 | 1 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=MYSTRUCT_INT_DOT | %FileCheck %s -check-prefix=MYSTRUCT_INT_DOT
|
2 | 2 | // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=META_MYSTRUCT_INT_DOT | %FileCheck %s -check-prefix=META_MYSTRUCT_INT_DOT
|
| 3 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONDITIONAL_OVERLOAD_ARG | %FileCheck %s -check-prefix=CONDITIONAL_OVERLOAD_ARG |
| 4 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONDITIONAL_OVERLOAD_INIT_ARG | %FileCheck %s -check-prefix=CONDITIONAL_OVERLOAD_ARG |
| 5 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONDITIONAL_INAPPLICABLE_ARG | %FileCheck %s -check-prefix=CONDITIONAL_INAPPLICABLE_ARG |
3 | 6 |
|
4 | 7 | protocol SomeProto {
|
5 | 8 | associatedtype Assoc
|
@@ -70,3 +73,44 @@ func foo(s: MyStruct<Int>) {
|
70 | 73 | // META_MYSTRUCT_INT_DOT-DAG: Decl[InstanceMethod]/Super: protoExt_None_AssocEqInt({#(self): MyStruct<Int>#})[#(U) -> Int#]; name=protoExt_None_AssocEqInt(self: MyStruct<Int>)
|
71 | 74 | // META_MYSTRUCT_INT_DOT: End completions
|
72 | 75 | }
|
| 76 | + |
| 77 | +//https://bugs.swift.org/browse/SR-9938 |
| 78 | +enum Fruit { case apple } |
| 79 | +enum Vegetable { case broccoli } |
| 80 | +enum Meat { case chicken } |
| 81 | + |
| 82 | +protocol EatsFruit { } |
| 83 | +protocol EatsVegetables { } |
| 84 | +protocol EatsMeat { } |
| 85 | + |
| 86 | +struct Chef <Client> { } |
| 87 | + |
| 88 | +extension Chef where Client: EatsFruit { |
| 89 | + init(_ favorite: Fruit) {} |
| 90 | + func cook(_ food: Fruit) { } |
| 91 | +} |
| 92 | +extension Chef where Client: EatsVegetables { |
| 93 | + init(_ favorite: Vegetable) {} |
| 94 | + func cook(_ food: Vegetable) { } |
| 95 | +} |
| 96 | +extension Chef where Client: EatsMeat { |
| 97 | + init(favorite: Meat) {} |
| 98 | + func cook(_ food: Meat) { } |
| 99 | + func eat(_ food: Meat) {} |
| 100 | +} |
| 101 | + |
| 102 | +struct Vegetarian: EatsFruit, EatsVegetables { } |
| 103 | + |
| 104 | +func testVegetarian(chef: Chef<Vegetarian>) { |
| 105 | + chef.cook(.#^CONDITIONAL_OVERLOAD_ARG^#) |
| 106 | +// CONDITIONAL_OVERLOAD_ARG: Begin completions, 2 items |
| 107 | +// CONDITIONAL_OVERLOAD_ARG-DAG: Decl[EnumElement]/ExprSpecific: apple[#Fruit#]; name=apple |
| 108 | +// CONDITIONAL_OVERLOAD_ARG-DAG: Decl[EnumElement]/ExprSpecific: broccoli[#Vegetable#]; name=broccoli |
| 109 | +// CONDITIONAL_OVERLOAD_ARG: End completions |
| 110 | + |
| 111 | + var chefMeta: Chef<Vegetarian>.Type = Chef<Vegetarian>.self |
| 112 | + let _ = chefMeta.init(.#^CONDITIONAL_OVERLOAD_INIT_ARG^#) |
| 113 | + |
| 114 | + chef.eat(.#^CONDITIONAL_INAPPLICABLE_ARG^#) |
| 115 | +// CONDITIONAL_INAPPLICABLE_ARG-NOT: Begin completion |
| 116 | +} |
0 commit comments