Skip to content

Commit

Permalink
Merge pull request apple#34295 from xymus/require-explicit-avail-igno…
Browse files Browse the repository at this point in the history
…re-implicit

[Sema] Don't require explicit availability for implicit decls
  • Loading branch information
xymus committed Oct 14, 2020
2 parents 2c3a6e0 + 8307a8d commit 5d21200
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Sema/TypeCheckAvailability.cpp
Expand Up @@ -2900,9 +2900,10 @@ static bool declNeedsExplicitAvailability(const Decl *decl) {
return false;
}

// Skip functions emitted into clients or SPI.
// Skip functions emitted into clients, SPI or implicit.
if (decl->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>() ||
decl->isSPI())
decl->isSPI() ||
decl->isImplicit())
return false;

// Warn on decls without an introduction version.
Expand Down
8 changes: 8 additions & 0 deletions test/attr/require_explicit_availability.swift
Expand Up @@ -164,3 +164,11 @@ extension SomeClass { // expected-warning {{public declarations should have an a
set(newValue) { }
}
}

@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, macCatalyst 13.0, *)
public struct StructWithImplicitMembers { }

extension StructWithImplicitMembers: Hashable { }
// expected-note @-1 {{add @available attribute to enclosing extension}}
// expected-warning @-2 {{public declarations should have an availability attribute when building with -require-explicit-availability}}
// expected-error @-3 {{'StructWithImplicitMembers' is only available in macOS 10.15 or newer}}

0 comments on commit 5d21200

Please sign in to comment.