File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2470,6 +2470,12 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *parsedAttr) {
24702470 // not diagnosed previously, so only emit a warning in that case.
24712471 if (isa<ExtensionDecl>(DC->getTopmostDeclarationDeclContext ()))
24722472 limit = DiagnosticBehavior::Warning;
2473+ } else if (enclosingAttr.getPlatform () != attr->getPlatform ()) {
2474+ // Downgrade to a warning when the limiting attribute is for a more
2475+ // specific platform.
2476+ if (inheritsAvailabilityFromPlatform (enclosingAttr.getPlatform (),
2477+ attr->getPlatform ()))
2478+ limit = DiagnosticBehavior::Warning;
24732479 }
24742480 diagnose (D->isImplicit () ? enclosingDecl->getLoc ()
24752481 : parsedAttr->getLocation (),
Original file line number Diff line number Diff line change @@ -164,3 +164,17 @@ public extension UnavailableOniOS { // ok
164164public struct AvailableOnMacCatalyst { }
165165
166166public extension AvailableOnMacCatalyst { } // ok
167+
168+ @available ( iOS, introduced: 14.0 )
169+ @available ( macCatalyst, introduced: 14.5 )
170+ public struct AvailableLaterOnMacCatalyst { // expected-note {{enclosing scope requires availability of Mac Catalyst 14.5 or newer}}
171+ @available ( iOS, introduced: 14.0 ) // expected-warning {{instance method cannot be more available than enclosing scope}}
172+ func iOSOnly( ) { }
173+
174+ @available ( macCatalyst, introduced: 14.5 )
175+ func macCatalystOnly( ) { }
176+
177+ @available ( iOS, introduced: 14.0 )
178+ @available ( macCatalyst, introduced: 14.5 )
179+ func iOSAndMacCatalyst( ) { }
180+ }
You can’t perform that action at this time.
0 commit comments