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/access_corner_case.swift
+22-5Lines changed: 22 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -26,8 +26,8 @@ private protocol S : R {
26
26
}
27
27
28
28
extensionS{
29
-
publicfunc publicRequirement(){}
30
-
internalfunc internalRequirement(){}
29
+
publicfunc publicRequirement(){} // expected-note {{mark the instance method as 'public' to satisfy the requirement}}
30
+
internalfunc internalRequirement(){} // expected-note {{mark the instance method as 'internal' to satisfy the requirement}}
31
31
fileprivatefunc fileprivateRequirement(){}
32
32
fileprivatefunc privateRequirement(){}
33
33
@@ -38,6 +38,8 @@ extension S {
38
38
publicstructT:S{}
39
39
// expected-error@-1 {{type 'T' does not conform to protocol 'S'}}
40
40
// expected-note@-2 {{add stubs for conformance}}
41
+
// expected-warning@-3 {{method 'internalRequirement()' must be as accessible as its enclosing type because it matches a requirement in protocol 'Q'}}
42
+
// expected-warning@-4 {{method 'publicRequirement()' must be as accessible as its enclosing type because it matches a requirement in protocol 'P'}}
41
43
42
44
protocolQpkg:Pkg{
43
45
func internalRequirement()
@@ -53,9 +55,9 @@ private protocol Spkg : Rpkg {
53
55
}
54
56
55
57
extensionSpkg{
56
-
publicfunc publicRequirement(){}
57
-
packagefunc packageRequirement(){}
58
-
internalfunc internalRequirement(){}
58
+
publicfunc publicRequirement(){} // expected-note {{mark the instance method as 'public' to satisfy the requirement}}
59
+
packagefunc packageRequirement(){} // expected-note {{mark the instance method as 'package' to satisfy the requirement}}
60
+
internalfunc internalRequirement(){} // expected-note {{mark the instance method as 'internal' to satisfy the requirement}}
59
61
fileprivatefunc fileprivateRequirement(){}
60
62
fileprivatefunc privateRequirement(){}
61
63
@@ -66,6 +68,9 @@ extension Spkg {
66
68
publicstructTpkg:Spkg{}
67
69
// expected-error@-1 {{type 'Tpkg' does not conform to protocol 'Spkg'}}
68
70
// expected-note@-2 {{add stubs for conformance}}
71
+
// expected-warning@-3 {{method 'internalRequirement()' must be as accessible as its enclosing type because it matches a requirement in protocol 'Qpkg'}}
72
+
// expected-warning@-4 {{method 'packageRequirement()' must be as accessible as its enclosing type because it matches a requirement in protocol 'Pkg'}}
73
+
// expected-warning@-5 {{method 'publicRequirement()' must be as accessible as its enclosing type because it matches a requirement in protocol 'P'}}
69
74
70
75
// This is also OK
71
76
@usableFromInline
@@ -111,3 +116,15 @@ extension Q2pkg {
111
116
}
112
117
113
118
publicstructT2pkg:Q2pkg{} // expected-error {{method 'publicRequirement()' must be declared public because it matches a requirement in public protocol 'P2'}}
119
+
120
+
publicstructFoo{
121
+
publicinit(value:Int){}
122
+
}
123
+
publicprotocolPublicProtocol{
124
+
init?(integer:Int)
125
+
}
126
+
protocolInternalProtocol:PublicProtocol{}
127
+
extensionInternalProtocol{
128
+
publicinit(integer:Int){} // expected-note {{mark the initializer as 'public' to satisfy the requirement}}
129
+
}
130
+
extensionFoo:PublicProtocol,InternalProtocol{} // expected-warning {{initializer 'init(integer:)' must be as accessible as its enclosing type because it matches a requirement in protocol 'PublicProtocol'}}
0 commit comments