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) {
8686}
8787
8888static 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+
8997 auto protocols = ED->getLocalProtocols (ConformanceLookupKind::OnlyExplicit);
9098 for (const ProtocolDecl *PD : protocols) {
9199 AccessScope scope =
Original file line number Diff line number Diff line change @@ -237,3 +237,23 @@ extension StructWithImplicitMembers: Hashable { }
237237// expected-note @-1 {{add @available attribute to enclosing extension}}
238238// expected-warning @-2 {{public declarations should have an availability attribute with an introduction version}}
239239// 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