|
| 1 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=METATYPE_UNRESOLVED | %FileCheck %s -check-prefix=METATYPE_UNRESOLVED |
| 2 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=METATYPE_INT | %FileCheck %s -check-prefix=METATYPE_INT |
| 3 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INSTANCE_INT | %FileCheck %s -check-prefix=INSTANCE_INT |
| 4 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=METATYPE_ARCHETYPE | %FileCheck %s -check-prefix=METATYPE_ARCHETYPE |
| 5 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INSTANCE_ARCHETYPE | %FileCheck %s -check-prefix=INSTANCE_ARCHETYPE |
| 6 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=METATYPE_LABEL | %FileCheck %s -check-prefix=METATYPE_LABEL |
| 7 | +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=INSTANCE_LABEL | %FileCheck %s -check-prefix=INSTANCE_LABEL |
| 8 | + |
| 9 | +struct MyStruct<T> { |
| 10 | + static subscript(x: Int, static defValue: T) -> MyStruct<T> { |
| 11 | + fatalError() |
| 12 | + } |
| 13 | + subscript(x: Int, instance defValue: T) -> Int { |
| 14 | + fatalError() |
| 15 | + } |
| 16 | +} |
| 17 | + |
| 18 | +func test1() { |
| 19 | + let _ = MyStruct #^METATYPE_UNRESOLVED^# |
| 20 | +// METATYPE_UNRESOLVED: Begin completions, 4 items |
| 21 | +// METATYPE_UNRESOLVED-DAG: Decl[Subscript]/CurrNominal: [{#(x): Int#}, {#static: _#}][#MyStruct<_>#]; |
| 22 | +// METATYPE_UNRESOLVED-DAG: Decl[Constructor]/CurrNominal: ()[#MyStruct<_>#]; |
| 23 | +// METATYPE_UNRESOLVED-DAG: Keyword[self]/CurrNominal: .self[#MyStruct<_>.Type#]; |
| 24 | +// METATYPE_UNRESOLVED-DAG: Keyword/CurrNominal: .Type[#MyStruct<_>.Type#]; |
| 25 | +// METATYPE_UNRESOLVED: End completions |
| 26 | + |
| 27 | + |
| 28 | + let _ = MyStruct<Int> #^METATYPE_INT^# |
| 29 | +// METATYPE_INT: Begin completions, 4 items |
| 30 | +// METATYPE_INT-DAG: Decl[Subscript]/CurrNominal: [{#(x): Int#}, {#static: Int#}][#MyStruct<Int>#]; |
| 31 | +// METATYPE_INT-DAG: Decl[Constructor]/CurrNominal: ()[#MyStruct<Int>#]; |
| 32 | +// METATYPE_INT-DAG: Keyword[self]/CurrNominal: .self[#MyStruct<Int>.Type#]; |
| 33 | +// METATYPE_INT-DAG: Keyword/CurrNominal: .Type[#MyStruct<Int>.Type#]; |
| 34 | +// METATYPE_INT: End completions |
| 35 | + |
| 36 | + let _ = MyStruct<Int>()#^INSTANCE_INT^# |
| 37 | +// INSTANCE_INT: Begin completions, 2 items |
| 38 | +// INSTANCE_INT-DAG: Decl[Subscript]/CurrNominal: [{#(x): Int#}, {#instance: Int#}][#Int#]; |
| 39 | +// INSTANCE_INT-DAG: Keyword[self]/CurrNominal: .self[#MyStruct<Int>#]; |
| 40 | +// INSTANCE_INT: End completions |
| 41 | + |
| 42 | +} |
| 43 | +func test2<U>(value: MyStruct<U>) { |
| 44 | + let _ = MyStruct<U>#^METATYPE_ARCHETYPE^# |
| 45 | +// METATYPE_ARCHETYPE: Begin completions, 4 items |
| 46 | +// METATYPE_ARCHETYPE-DAG: Decl[Subscript]/CurrNominal: [{#(x): Int#}, {#static: U#}][#MyStruct<U>#]; |
| 47 | +// METATYPE_ARCHETYPE-DAG: Decl[Constructor]/CurrNominal: ()[#MyStruct<U>#]; |
| 48 | +// METATYPE_ARCHETYPE-DAG: Keyword[self]/CurrNominal: .self[#MyStruct<U>.Type#]; |
| 49 | +// METATYPE_ARCHETYPE-DAG: Keyword/CurrNominal: .Type[#MyStruct<U>.Type#]; |
| 50 | +// METATYPE_ARCHETYPE: End completions |
| 51 | + |
| 52 | + let _ = value #^INSTANCE_ARCHETYPE^# |
| 53 | +// INSTANCE_ARCHETYPE: Begin completions, 2 items |
| 54 | +// INSTANCE_ARCHETYPE-DAG: Decl[Subscript]/CurrNominal: [{#(x): Int#}, {#instance: U#}][#Int#]; |
| 55 | +// INSTANCE_ARCHETYPE-DAG: Keyword[self]/CurrNominal: .self[#MyStruct<U>#]; |
| 56 | +// INSTANCE_ARCHETYPE: End completions |
| 57 | + |
| 58 | + let _ = MyStruct<U>[42, #^METATYPE_LABEL^# |
| 59 | +// METATYPE_LABEL: Begin completions, 1 items |
| 60 | +// METATYPE_LABEL-DAG: Keyword/ExprSpecific: static: [#Argument name#]; |
| 61 | +// METATYPE_LABEL: End completions |
| 62 | + |
| 63 | + let _ = value[42, #^INSTANCE_LABEL^# |
| 64 | +// INSTANCE_LABEL: Begin completions, 1 items |
| 65 | +// INSTANCE_LABEL-DAG: Keyword/ExprSpecific: instance: [#Argument name#]; |
| 66 | +// INSTANCE_LABEL: End completions |
| 67 | +} |
0 commit comments