File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,14 @@ bool swift::isExported(const ValueDecl *VD) {
86
86
}
87
87
88
88
static bool hasConformancesToPublicProtocols (const ExtensionDecl *ED) {
89
+ auto nominal = ED->getExtendedNominal ();
90
+ if (!nominal)
91
+ return false ;
92
+
93
+ // Extensions of protocols cannot introduce additional conformances.
94
+ if (isa<ProtocolDecl>(nominal))
95
+ return false ;
96
+
89
97
auto protocols = ED->getLocalProtocols (ConformanceLookupKind::OnlyExplicit);
90
98
for (const ProtocolDecl *PD : protocols) {
91
99
AccessScope scope =
Original file line number Diff line number Diff line change @@ -237,3 +237,23 @@ extension StructWithImplicitMembers: Hashable { }
237
237
// expected-note @-1 {{add @available attribute to enclosing extension}}
238
238
// expected-warning @-2 {{public declarations should have an availability attribute with an introduction version}}
239
239
// expected-error @-3 {{'StructWithImplicitMembers' is only available in macOS 10.15 or newer}}
240
+
241
+ extension PublicProtocol { }
242
+
243
+ extension PublicProtocol {
244
+ internal var internalVar : Bool { return true }
245
+ }
246
+
247
+ extension PublicProtocol { // expected-warning {{public declarations should have an availability attribute with an introduction version}}
248
+ public var publicVar : Bool { return true } // expected-warning {{public declarations should have an availability attribute with an introduction version}}
249
+ }
250
+
251
+ extension Error { }
252
+
253
+ extension Error {
254
+ internal var internalVar : Bool { return true }
255
+ }
256
+
257
+ extension Error { // expected-warning {{public declarations should have an availability attribute with an introduction version}}
258
+ public var publicVar : Bool { return true } // expected-warning {{public declarations should have an availability attribute with an introduction version}}
259
+ }
You can’t perform that action at this time.
0 commit comments