File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -4509,12 +4509,16 @@ void AttributeChecker::checkOriginalDefinedInAttrs(
4509
4509
void AttributeChecker::checkAvailableAttrs (ArrayRef<AvailableAttr *> Attrs) {
4510
4510
if (Attrs.empty ())
4511
4511
return ;
4512
- // If all available are spi available, we should use @_spi instead.
4513
- if (std::all_of (Attrs.begin (), Attrs.end (), [](AvailableAttr *AV) {
4514
- return AV->IsSPI ;
4515
- })) {
4516
- diagnose (D->getLoc (), diag::spi_preferred_over_spi_available);
4517
- };
4512
+
4513
+ // Only diagnose top level decls since nested ones may have inherited availability.
4514
+ if (!D->getDeclContext ()->getInnermostDeclarationDeclContext ()) {
4515
+ // If all available are spi available, we should use @_spi instead.
4516
+ if (std::all_of (Attrs.begin (), Attrs.end (), [](AvailableAttr *AV) {
4517
+ return AV->IsSPI ;
4518
+ })) {
4519
+ diagnose (D->getLoc (), diag::spi_preferred_over_spi_available);
4520
+ }
4521
+ }
4518
4522
}
4519
4523
4520
4524
void AttributeChecker::checkBackDeployAttrs (ArrayRef<BackDeployAttr *> Attrs) {
Original file line number Diff line number Diff line change @@ -17,3 +17,8 @@ public class SPIClass5 {}
17
17
18
18
@_spi_available ( mscos 10 . 15 , * ) // expected-warning {{unrecognized platform name 'mscos'; did you mean 'macOS'?}} {{17-22=macOS}}
19
19
public class SPIClass6 { }
20
+
21
+ public class ClassWithMembers {
22
+ @_spi_available ( macOS 10 . 15 , * )
23
+ public func spiFunc( ) { } // Ok, this declaration is not top level
24
+ }
You can’t perform that action at this time.
0 commit comments