Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,9 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) {
if (!AttrRange.isContainedIn(*EnclosingAnnotatedRange)) {
// Members of extensions of nominal types with available ranges were
// not diagnosed previously, so only emit a warning in that case.
auto limit = (enclosingDecl != parent && isa<ExtensionDecl>(parent))
bool inExtension = isa<ExtensionDecl>(
D->getDeclContext()->getTopmostDeclarationDeclContext());
auto limit = (enclosingDecl != parent && inExtension)
? DiagnosticBehavior::Warning
: DiagnosticBehavior::Unspecified;
diagnose(D->isImplicit() ? enclosingDecl->getLoc()
Expand Down
7 changes: 6 additions & 1 deletion test/attr/attr_availability_osx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func doSomethingDeprecatedOniOS() { }
doSomethingDeprecatedOniOS() // okay

@available(macOS 10.10, *)
struct TestStruct {} // expected-note {{enclosing scope requires availability of macOS 10.10 or newer}}
struct TestStruct {} // expected-note 2 {{enclosing scope requires availability of macOS 10.10 or newer}}

@available(macOS 10.10, *)
extension TestStruct { // expected-note {{enclosing scope requires availability of macOS 10.10 or newer}}
Expand All @@ -107,6 +107,11 @@ extension TestStruct { // expected-note {{enclosing scope requires availability
extension TestStruct {
@available(macOS 10.9, *) // expected-warning {{instance method cannot be more available than enclosing scope}}
func doFifthThing() {}

struct NestedStruct {
@available(macOS 10.9, *) // expected-warning {{instance method cannot be more available than enclosing scope}}
func doSixthThing() {}
}
}

@available(macOS 10.11, *)
Expand Down