@@ -2396,8 +2396,7 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *parsedAttr) {
23962396
23972397 // Skip the remaining diagnostics in swiftinterfaces.
23982398 auto *DC = D->getDeclContext ();
2399- auto *SF = DC->getParentSourceFile ();
2400- if (SF && SF->Kind == SourceFileKind::Interface)
2399+ if (DC->isInSwiftinterface ())
24012400 return ;
24022401
24032402 // The remaining diagnostics are only for attributes that are active.
@@ -4549,8 +4548,7 @@ void AttributeChecker::visitCustomAttr(CustomAttr *attr) {
45494548 // Module interfaces don't print bodies for all getters, so allow getters
45504549 // that don't have a body if we're compiling a module interface.
45514550 // Within a protocol definition, there will never be a body.
4552- SourceFile *parent = storage->getDeclContext ()->getParentSourceFile ();
4553- bool isInInterface = parent && parent->Kind == SourceFileKind::Interface;
4551+ bool isInInterface = storage->getDeclContext ()->isInSwiftinterface ();
45544552 if (!isInInterface && !getter->hasBody () &&
45554553 !isa<ProtocolDecl>(storage->getDeclContext ()))
45564554 return true ;
@@ -5262,9 +5260,7 @@ TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable(const Decl *D) {
52625260 // An enum element with an associated value cannot be potentially
52635261 // unavailable.
52645262 if (EED->hasAssociatedValues ()) {
5265- auto *SF = DC->getParentSourceFile ();
5266-
5267- if (SF->Kind == SourceFileKind::Interface) {
5263+ if (DC->isInSwiftinterface ()) {
52685264 return diag::availability_enum_element_no_potential_warn;
52695265 } else {
52705266 return diag::availability_enum_element_no_potential;
@@ -7885,8 +7881,7 @@ void AttributeChecker::visitMacroRoleAttr(MacroRoleAttr *attr) {
78857881 break ;
78867882 case MacroRole::Conformance: {
78877883 // Suppress the conformance macro error in swiftinterfaces.
7888- SourceFile *file = D->getDeclContext ()->getParentSourceFile ();
7889- if (file && file->Kind == SourceFileKind::Interface)
7884+ if (D->getDeclContext ()->isInSwiftinterface ())
78907885 break ;
78917886
78927887 diagnoseAndRemoveAttr (attr, diag::conformance_macro)
0 commit comments