- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathcomplete_from_constraint_extensions.swift
53 lines (44 loc) · 1.92 KB
/
complete_from_constraint_extensions.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONSTRAINT1 | %FileCheck %s -check-prefix=CONSTRAINT1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONSTRAINT2 | %FileCheck %s -check-prefix=CONSTRAINT2
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONSTRAINT3 | %FileCheck %s -check-prefix=CONSTRAINT3
publicprotocolP1{}
publicprotocolP2{}
publicstructExample<T:Any>{}
extensionExamplewhere T:P1{
func P1Method(){}
}
extensionExamplewhere T:P2{
func P2Method(){}
}
publicstructS1:P1{}
publicstructS2:P2{}
func foo1(){
varI1=Example<S1>()
I1.#^CONSTRAINT1^#
}
// CONSTRAINT1: Begin completions, 2 items
// CONSTRAINT1-NEXT: Keyword[self]/CurrNominal: self[#Example<S1>#]; name=self
// CONSTRAINT1-NEXT: Decl[InstanceMethod]/CurrNominal: P1Method()[#Void#]; name=P1Method()
func foo2(){
varI2=Example<S2>()
I2.#^CONSTRAINT2^#
}
// CONSTRAINT2: Begin completions, 2 items
// CONSTRAINT2-NEXT: Keyword[self]/CurrNominal: self[#Example<S2>#]; name=self
// CONSTRAINT2-NEXT: Decl[InstanceMethod]/CurrNominal: P2Method()[#Void#]; name=P2Method()
protocolMyIndexable{}
protocolMyCollection:MyIndexable{
associatedtypeIndices=MyDefaultIndices<Self>
varindices:Indices{get}
}
structMyDefaultIndices<Elements :MyIndexable>:MyCollection{}
extensionMyCollectionwhere Indices ==MyDefaultIndices<Self>{
varindices:MyDefaultIndices<Self>{returnMyDefaultIndices()}
}
structConcreteCollection<Element>:MyCollection{}
func foo3(){
ConcreteCollection<Int>().#^CONSTRAINT3^#
}
// CONSTRAINT3: Begin completions, 2 items
// CONSTRAINT3-NEXT: Keyword[self]/CurrNominal: self[#ConcreteCollection<Int>#]; name=self
// CONSTRAINT3-NEXT: Decl[InstanceVar]/Super: indices[#MyDefaultIndices<ConcreteCollection<Int>>#]; name=indices