AST: Introduce and adopt DeclContext::isInSwiftinterface().

Checking whether a declaration is in a `.swiftinterface` is a very common query
that is made somewhat awkward because declarations are not always in source
files. To make these checks more ergonomic, expose a convenience on
DeclContext.
This commit is contained in:
Allan Shortlidge
2025-01-27 19:07:11 -08:00
parent 459e59265d
commit e019a32122
14 changed files with 46 additions and 62 deletions

View File

@@ -1335,9 +1335,8 @@ static bool shouldAttemptInitializerSynthesis(const NominalTypeDecl *decl) {
return false;
// Don't add implicit constructors in module interfaces.
if (auto *SF = decl->getParentSourceFile())
if (SF->Kind == SourceFileKind::Interface)
return false;
if (decl->getDeclContext()->isInSwiftinterface())
return false;
// Don't attempt if we know the decl is invalid.
if (decl->isInvalid())