Skip to content

Commit 5d21200

Browse files
authored
Merge pull request swiftlang#34295 from xymus/require-explicit-avail-ignore-implicit
[Sema] Don't require explicit availability for implicit decls
2 parents 2c3a6e0 + 8307a8d commit 5d21200

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,9 +2900,10 @@ static bool declNeedsExplicitAvailability(const Decl *decl) {
29002900
return false;
29012901
}
29022902

2903-
// Skip functions emitted into clients or SPI.
2903+
// Skip functions emitted into clients, SPI or implicit.
29042904
if (decl->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>() ||
2905-
decl->isSPI())
2905+
decl->isSPI() ||
2906+
decl->isImplicit())
29062907
return false;
29072908

29082909
// Warn on decls without an introduction version.

test/attr/require_explicit_availability.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,11 @@ extension SomeClass { // expected-warning {{public declarations should have an a
164164
set(newValue) { }
165165
}
166166
}
167+
168+
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, macCatalyst 13.0, *)
169+
public struct StructWithImplicitMembers { }
170+
171+
extension StructWithImplicitMembers: Hashable { }
172+
// expected-note @-1 {{add @available attribute to enclosing extension}}
173+
// expected-warning @-2 {{public declarations should have an availability attribute when building with -require-explicit-availability}}
174+
// expected-error @-3 {{'StructWithImplicitMembers' is only available in macOS 10.15 or newer}}

0 commit comments

Comments
 (0)