File tree 2 files changed +20
-0
lines changed
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) {
2470
2470
// not diagnosed previously, so only emit a warning in that case.
2471
2471
if (isa<ExtensionDecl>(DC->getTopmostDeclarationDeclContext ()))
2472
2472
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;
2473
2479
}
2474
2480
diagnose (D->isImplicit () ? enclosingDecl->getLoc ()
2475
2481
: parsedAttr->getLocation (),
Original file line number Diff line number Diff line change @@ -164,3 +164,17 @@ public extension UnavailableOniOS { // ok
164
164
public struct AvailableOnMacCatalyst { }
165
165
166
166
public 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