@@ -2396,8 +2396,7 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *parsedAttr) {
2396
2396
2397
2397
// Skip the remaining diagnostics in swiftinterfaces.
2398
2398
auto *DC = D->getDeclContext();
2399
- auto *SF = DC->getParentSourceFile ();
2400
- if (SF && SF->Kind == SourceFileKind::Interface)
2399
+ if (DC->isInSwiftinterface())
2401
2400
return;
2402
2401
2403
2402
// The remaining diagnostics are only for attributes that are active.
@@ -4549,8 +4548,7 @@ void AttributeChecker::visitCustomAttr(CustomAttr *attr) {
4549
4548
// Module interfaces don't print bodies for all getters, so allow getters
4550
4549
// that don't have a body if we're compiling a module interface.
4551
4550
// 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();
4554
4552
if (!isInInterface && !getter->hasBody() &&
4555
4553
!isa<ProtocolDecl>(storage->getDeclContext()))
4556
4554
return true;
@@ -5262,9 +5260,7 @@ TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable(const Decl *D) {
5262
5260
// An enum element with an associated value cannot be potentially
5263
5261
// unavailable.
5264
5262
if (EED->hasAssociatedValues()) {
5265
- auto *SF = DC->getParentSourceFile ();
5266
-
5267
- if (SF->Kind == SourceFileKind::Interface) {
5263
+ if (DC->isInSwiftinterface()) {
5268
5264
return diag::availability_enum_element_no_potential_warn;
5269
5265
} else {
5270
5266
return diag::availability_enum_element_no_potential;
@@ -7885,8 +7881,7 @@ void AttributeChecker::visitMacroRoleAttr(MacroRoleAttr *attr) {
7885
7881
break;
7886
7882
case MacroRole::Conformance: {
7887
7883
// 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())
7890
7885
break;
7891
7886
7892
7887
diagnoseAndRemoveAttr(attr, diag::conformance_macro)
0 commit comments