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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
// RUN: %batch-code-completion
protocol MyProtocol {
init(init1: Int)
init(init2: Int)
func method(method1: Int)
func method(method2: Int)
}
extension MyProtocol {
init(init2: Int) { self.init(init1: init2) }
init(init3: Int) { self.init(init1: init3) }
func method(method2: Int) {}
func method(method3: Int) {}
}
class Base {
init(init4: Int) { }
func method(method4: Int) {}
}
class MyClass: Base, MyProtocol {
required init(init1: Int) { super.init(init4: init1) }
required init(init2: Int) { super.init(init4: init1) }
init(init3: Int) { super.init(init4: init1) }
override init(init4: Int) { super.init(init4: init1) }
func method(method1: Int)
func method(method2: Int) {}
func method(method3: Int) {}
override func method(method4: Int) {}
}
func testConstructer() {
MyClass(#^INITIALIZER^#)
// INITIALIZER: Begin completions, 4 items
// INITIALIZER-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#init1: Int#}[')'][#MyClass#];
// INITIALIZER-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#init2: Int#}[')'][#MyClass#];
// INITIALIZER-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#init3: Int#}[')'][#MyClass#];
// INITIALIZER-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#init4: Int#}[')'][#MyClass#];
}
func testMethod(obj: MyClass) {
obj.method(#^METHOD^#)
// METHOD: Begin completions, 4 items
// METHOD-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#method1: Int#}[')'][#Void#];
// METHOD-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#method2: Int#}[')'][#Void#];
// METHOD-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#method3: Int#}[')'][#Void#];
// METHOD-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#method4: Int#}[')'][#Void#];
}
protocol HasUnavailable {}
extension HasUnavailable {
func method(method1: Int) {}
@available(*, unavailable)
func method(method2: Int) {}
}
struct MyStruct: HasUnavailable {
@available(*, unavailable)
func method(method1: Int) {}
func method(method2: Int) {}
}
func testUnavailable(val: MyStruct) {
val.method(#^AVAILABILITY^#)
// AVAILABILITY: Begin completions, 2 items
// AVAILABILITY-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#method2: Int#}[')'][#Void#];
// AVAILABILITY-DAG: Decl[InstanceMethod]/Super/Flair[ArgLabels]: ['(']{#method1: Int#}[')'][#Void#];
}
struct TestStatic {
static func method(_ self: TestStatic) -> () -> Void {}
func method() -> Void {}
}
func testStaticFunc() {
TestStatic.method(#^STATIC^#)
// STATIC-DAG: Decl[StaticMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#(self): TestStatic#}[')'][#() -> Void#];
// STATIC-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#(self): TestStatic#}[')'][#() -> Void#];
}
protocol TestShadowedProtocol {}
extension TestShadowedProtocol {
func argOverloaded(arg: String) {}
func argOverloaded(arg: Int) {}
func returnTypeOverloaded() -> String {}
func returnTypeOverloaded() -> Int {}
}
struct TestShadowedStruct: TestShadowedProtocol {
func argOverloaded(arg: String) {}
func returnTypeOverloaded() -> String {}
func test() {
self.argOverloaded(#^ARG_OVERLOADED^#)
// ARG_OVERLOADED: Begin completions, 2 items
// ARG_OVERLOADED-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['(']{#arg: String#}[')'][#Void#]; name=arg:
// ARG_OVERLOADED-DAG: Decl[InstanceMethod]/Super/Flair[ArgLabels]: ['(']{#arg: Int#}[')'][#Void#]; name=arg:
self.returnTypeOverloaded(#^RETURN_OVERLOADED^#)
// RETURN_OVERLOADED: Begin completions, 2 items
// RETURN_OVERLOADED-DAG: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]: ['('][')'][#String#]; name=
// RETURN_OVERLOADED-DAG: Decl[InstanceMethod]/Super/Flair[ArgLabels]: ['('][')'][#Int#]; name=
}
}
|