You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/decl/protocol/conforms/fixit_stub.swift
+65-20Lines changed: 65 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
// RUN: %target-parse-verify-swift
2
2
3
3
protocolProtocol1{
4
-
func foo(arg1:Int, arg2:String)->String // expected-note{{protocol requires function 'foo(arg1:arg2:)' with type '(Int, String) -> String'; do you want to add a stub?}} {{27-27=\n internal func foo(arg1: Int, arg2: String) -> String {\n <#code#>\n \}\n}}
5
-
func bar()throws->String // expected-note{{protocol requires function 'bar()' with type '() throws -> String'; do you want to add a stub?}} {{27-27=\n internal func bar() throws -> String {\n <#code#>\n \}\n}}
6
-
init(arg:Int) // expected-note{{protocol requires initializer 'init(arg:)' with type '(arg: Int)'; do you want to add a stub?}} {{27-27=\n internal init(arg: Int) {\n <#code#>\n \}\n}}
7
-
varbaz:Int{get} // expected-note{{protocol requires property 'baz' with type 'Int'; do you want to add a stub?}} {{27-27=\n internal var baz: Int\n}}
8
-
varbaz2:Int{getset} // expected-note{{protocol requires property 'baz2' with type 'Int'; do you want to add a stub?}} {{27-27=\n internal var baz2: Int\n}}
9
-
subscript(arg:Int)->String{get} //expected-note{{rotocol requires subscript with type '(Int) -> String'; do you want to add a stub?}} {{27-27=\n internal subscript(arg: Int) -> String {\n <#code#>\n \}\n}}
10
-
subscript(arg1:Int, arg2:Int)->String{getset} //expected-note{{protocol requires subscript with type '(Int, Int) -> String'; do you want to add a stub?}} {{27-27=\n internal subscript(arg1: Int, arg2: Int) -> String {\n get {\n <#code#>\n \}\n set {\n <#code#>\n \}\n \}\n}}
4
+
func foo(arg1:Int, arg2:String)->String // expected-note{{protocol requires function 'foo(arg1:arg2:)' with type '(Int, String) -> String'; do you want to add a stub?}} {{27-27=\n func foo(arg1: Int, arg2: String) -> String {\n <#code#>\n \}\n}}
5
+
func bar()throws->String // expected-note{{protocol requires function 'bar()' with type '() throws -> String'; do you want to add a stub?}} {{27-27=\n func bar() throws -> String {\n <#code#>\n \}\n}}
6
+
init(arg:Int) // expected-note{{protocol requires initializer 'init(arg:)' with type '(arg: Int)'; do you want to add a stub?}} {{27-27=\n init(arg: Int) {\n <#code#>\n \}\n}}
7
+
varbaz:Int{get} // expected-note{{protocol requires property 'baz' with type 'Int'; do you want to add a stub?}} {{27-27=\n var baz: Int\n}}
8
+
varbaz2:Int{getset} // expected-note{{protocol requires property 'baz2' with type 'Int'; do you want to add a stub?}} {{27-27=\n var baz2: Int\n}}
9
+
subscript(arg:Int)->String{get} //expected-note{{rotocol requires subscript with type '(Int) -> String'; do you want to add a stub?}} {{27-27=\n subscript(arg: Int) -> String {\n <#code#>\n \}\n}}
10
+
subscript(arg1:Int, arg2:Int)->String{getset} //expected-note{{protocol requires subscript with type '(Int, Int) -> String'; do you want to add a stub?}} {{27-27=\n subscript(arg1: Int, arg2: Int) -> String {\n get {\n <#code#>\n \}\n set {\n <#code#>\n \}\n \}\n}}
11
11
}
12
12
13
13
classAdopter:Protocol1{ // expected-error{{type 'Adopter' does not conform to protocol 'Protocol1'}} expected-note{{candidate has non-matching type '()'}}
@@ -16,13 +16,13 @@ class Adopter: Protocol1 { // expected-error{{type 'Adopter' does not conform to
16
16
17
17
18
18
protocolProtocol2{
19
-
func foo(arg1:Int, arg2:String)->String // expected-note{{protocol requires function 'foo(arg1:arg2:)' with type '(Int, String) -> String'; do you want to add a stub?}} {{32-32=\n internal func foo(arg1: Int, arg2: String) -> String {\n <#code#>\n \}\n}}
20
-
func bar()throws->String // expected-note{{protocol requires function 'bar()' with type '() throws -> String'; do you want to add a stub?}} {{32-32=\n internal func bar() throws -> String {\n <#code#>\n \}\n}}
21
-
init(arg:Int) // expected-note{{protocol requires initializer 'init(arg:)' with type '(arg: Int)'; do you want to add a stub?}} {{32-32=\n internal init(arg: Int) {\n <#code#>\n \}\n}}
22
-
varbaz:Int{get} // expected-note{{protocol requires property 'baz' with type 'Int'; do you want to add a stub?}} {{32-32=\n internal var baz: Int {\n <#code#>\n \}\n}}
23
-
varbaz2:Int{getset} // expected-note{{protocol requires property 'baz2' with type 'Int'; do you want to add a stub?}} {{32-32=\n internal var baz2: Int {\n get {\n <#code#>\n \}\n set {\n <#code#>\n \}\n \}\n}}
24
-
subscript(arg:Int)->String{get} //expected-note{{rotocol requires subscript with type '(Int) -> String'; do you want to add a stub?}} {{32-32=\n internal subscript(arg: Int) -> String {\n <#code#>\n \}\n}}
25
-
subscript(arg1:Int, arg2:Int)->String{getset} //expected-note{{protocol requires subscript with type '(Int, Int) -> String'; do you want to add a stub?}} {{32-32=\n internal subscript(arg1: Int, arg2: Int) -> String {\n get {\n <#code#>\n \}\n set {\n <#code#>\n \}\n \}\n}}
19
+
func foo(arg1:Int, arg2:String)->String // expected-note{{protocol requires function 'foo(arg1:arg2:)' with type '(Int, String) -> String'; do you want to add a stub?}} {{32-32=\n func foo(arg1: Int, arg2: String) -> String {\n <#code#>\n \}\n}}
20
+
func bar()throws->String // expected-note{{protocol requires function 'bar()' with type '() throws -> String'; do you want to add a stub?}} {{32-32=\n func bar() throws -> String {\n <#code#>\n \}\n}}
21
+
init(arg:Int) // expected-note{{protocol requires initializer 'init(arg:)' with type '(arg: Int)'; do you want to add a stub?}} {{32-32=\n init(arg: Int) {\n <#code#>\n \}\n}}
22
+
varbaz:Int{get} // expected-note{{protocol requires property 'baz' with type 'Int'; do you want to add a stub?}} {{32-32=\n var baz: Int {\n <#code#>\n \}\n}}
23
+
varbaz2:Int{getset} // expected-note{{protocol requires property 'baz2' with type 'Int'; do you want to add a stub?}} {{32-32=\n var baz2: Int {\n get {\n <#code#>\n \}\n set {\n <#code#>\n \}\n \}\n}}
24
+
subscript(arg:Int)->String{get} //expected-note{{rotocol requires subscript with type '(Int) -> String'; do you want to add a stub?}} {{32-32=\n subscript(arg: Int) -> String {\n <#code#>\n \}\n}}
25
+
subscript(arg1:Int, arg2:Int)->String{getset} //expected-note{{protocol requires subscript with type '(Int, Int) -> String'; do you want to add a stub?}} {{32-32=\n subscript(arg1: Int, arg2: Int) -> String {\n get {\n <#code#>\n \}\n set {\n <#code#>\n \}\n \}\n}}
26
26
}
27
27
28
28
classAdopter2{} // expected-note{{candidate has non-matching type '()'}}
func foo()->Self // expected-note{{protocol requires function 'foo()' with type '() -> Self'; do you want to add a stub?}} {{47-47=\n internal func foo() -> Adopter5 {\n <#code#>\n \}\n}}
58
-
func foo(lhs:Self, rhs:Self)->Self //expected-note{{protocol requires function 'foo(lhs:rhs:)' with type '(Adopter5, Adopter5) -> Self'; do you want to add a stub?}} {{47-47=\n internal func foo(lhs: Adopter5, rhs: Adopter5) -> Adopter5 {\n <#code#>\n \}\n}}
57
+
func foo()->Self // expected-note{{protocol requires function 'foo()' with type '() -> Self'; do you want to add a stub?}} {{47-47=\n func foo() -> Adopter5 {\n <#code#>\n \}\n}}
58
+
func foo(lhs:Self, rhs:Self)->Self //expected-note{{protocol requires function 'foo(lhs:rhs:)' with type '(Adopter5, Adopter5) -> Self'; do you want to add a stub?}} {{47-47=\n func foo(lhs: Adopter5, rhs: Adopter5) -> Adopter5 {\n <#code#>\n \}\n}}
59
59
}
60
60
61
61
structAdopter5:ProtocolWithSelfRequirement{ //expected-error{{type 'Adopter5' does not conform to protocol 'ProtocolWithSelfRequirement'}}
func foo()->Self // expected-note{{protocol requires function 'foo()' with type '() -> Self'; do you want to add a stub?}} {{51-51=\n internal func foo() -> Adopter6 {\n <#code#>\n \}\n}}
68
-
func foo(lhs:Self, rhs:Self)->Self //expected-note{{protocol requires function 'foo(lhs:rhs:)' with type '(Adopter6, Adopter6) -> Self'; do you want to add a stub?}} {{51-51=\n internal func foo(lhs: Adopter6, rhs: Adopter6) -> Adopter6 {\n <#code#>\n \}\n}}
67
+
func foo()->Self // expected-note{{protocol requires function 'foo()' with type '() -> Self'; do you want to add a stub?}} {{51-51=\n func foo() -> Adopter6 {\n <#code#>\n \}\n}}
68
+
func foo(lhs:Self, rhs:Self)->Self //expected-note{{protocol requires function 'foo(lhs:rhs:)' with type '(Adopter6, Adopter6) -> Self'; do you want to add a stub?}} {{51-51=\n func foo(lhs: Adopter6, rhs: Adopter6) -> Adopter6 {\n <#code#>\n \}\n}}
func foo()->Self // expected-note{{protocol requires function 'foo()' with type '() -> Self'; do you want to add a stub?}} {{47-47=\n internal func foo() -> Self {\n <#code#>\n \}\n}}
79
-
func foo(lhs:Self, rhs:Self)->Self //expected-note{{protocol requires function 'foo(lhs:rhs:)' with type '(Adopter7, Adopter7) -> Self'; do you want to add a stub?}} {{47-47=\n internal func foo(lhs: Adopter7, rhs: Adopter7) -> Self {\n <#code#>\n \}\n}}
78
+
func foo()->Self // expected-note{{protocol requires function 'foo()' with type '() -> Self'; do you want to add a stub?}} {{47-47=\n func foo() -> Self {\n <#code#>\n \}\n}}
79
+
func foo(lhs:Self, rhs:Self)->Self //expected-note{{protocol requires function 'foo(lhs:rhs:)' with type '(Adopter7, Adopter7) -> Self'; do you want to add a stub?}} {{47-47=\n func foo(lhs: Adopter7, rhs: Adopter7) -> Self {\n <#code#>\n \}\n}}
80
80
}
81
81
82
82
classAdopter7:ProtocolWithSelfRequirement3{ //expected-error{{type 'Adopter7' does not conform to protocol 'ProtocolWithSelfRequirement3'}}
83
83
}
84
+
85
+
86
+
publicprotocolProtocolWithPublicAccess1{
87
+
func foo() // expected-note{{protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub?}} {{71-71=\n func foo() {\n <#code#>\n \}\n}}
// expected-error@-1{{type 'Adopter8' does not conform to protocol 'ProtocolWithPublicAccess1'}}
94
+
// expected-error@-2{{type 'Adopter8' does not conform to protocol 'ProtocolWithPublicAccess2'}}
95
+
}
96
+
97
+
publicprotocolProtocolWithPublicAccess3{
98
+
func foo() // expected-note{{protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub?}} {{78-78=\n public func foo() {\n <#code#>\n \}\n}}
99
+
}
100
+
publicprotocolProtocolWithPublicAccess4{
101
+
associatedtypeAssocType //expected-note{{protocol requires nested type 'AssocType'}} {{78-78=\n public typealias AssocType = <#type#>\n}}
// expected-error@-1{{type 'Adopter9' does not conform to protocol 'ProtocolWithPublicAccess3'}}
105
+
// expected-error@-2{{type 'Adopter9' does not conform to protocol 'ProtocolWithPublicAccess4'}}
106
+
}
107
+
108
+
privateprotocolProtocolWithPrivateAccess1{
109
+
func foo() // expected-note{{protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub?}} {{74-74=\n func foo() {\n <#code#>\n \}\n}}
// expected-error@-1{{type 'Adopter10' does not conform to protocol 'ProtocolWithPrivateAccess1'}}
116
+
// expected-error@-2{{type 'Adopter10' does not conform to protocol 'ProtocolWithPrivateAccess2'}}
117
+
}
118
+
119
+
privateprotocolProtocolWithPrivateAccess3{
120
+
func foo() // expected-note{{protocol requires function 'foo()' with type '() -> ()'; do you want to add a stub?}} {{81-81=\n func foo() {\n <#code#>\n \}\n}}
0 commit comments