Skip to content

Commit 1598382

Browse files
committed
Preperations for module support for ignoreDeprecationWarnings attribute
1 parent 3488d77 commit 1598382

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(_local, KnownToBeLocal,
736736
130)
737737

738738
SIMPLE_DECL_ATTR(ignoreDeprecationWarnings, IgnoreDeprecationWarnings,
739-
OnAbstractFunction | OnGenericType | OnVar | OnSubscript | OnEnumElement |
739+
OnAbstractFunction | OnGenericType | OnVar | OnSubscript | OnEnumElement | OnImport
740740
OnExtension | AllowMultipleAttributes |
741741
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
742742
131)

include/swift/AST/Import.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ enum class ImportFlags {
8585
Preconcurrency = 0x20,
8686

8787
/// Used for DenseMap.
88-
Reserved = 0x80
88+
Reserved = 0x80,
89+
90+
/// Silence all deprecation warnings coming from symbols imported from the module
91+
IgnoresDeprecationWarnings = 0x90
8992
};
9093

9194
/// \see ImportFlags

lib/Sema/ImportResolution.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,9 @@ UnboundImport::UnboundImport(ImportDecl *ID)
536536
if (ID->getAttrs().hasAttribute<ImplementationOnlyAttr>())
537537
import.options |= ImportFlags::ImplementationOnly;
538538

539+
if (ID->getAttrs().hasAttribute<IgnoreDeprecationWarningsAttr>())
540+
import.options |= ImportFlags.IgnoresDeprecationWarnings;
541+
539542
if (auto *privateImportAttr =
540543
ID->getAttrs().getAttribute<PrivateImportAttr>()) {
541544
import.options |= ImportFlags::PrivateImport;

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,9 @@ static bool hasExplicitSendableConformance(NominalTypeDecl *nominal,
686686
}
687687

688688
/// Find the import that makes the given nominal declaration available.
689-
static Optional<AttributedImport<ImportedModule>> findImportFor(
690-
NominalTypeDecl *nominal, const DeclContext *fromDC) {
689+
Optional<AttributedImport<ImportedModule>> findImportFor(
690+
ModuleDecl *nominalModule, ASTContext *nominalASTCtx, const DeclContext *fromDC) {
691691
// If the nominal type is from the current module, there's no import.
692-
auto nominalModule = nominal->getParentModule();
693692
if (nominalModule == fromDC->getParentModule())
694693
return None;
695694

@@ -704,7 +703,7 @@ static Optional<AttributedImport<ImportedModule>> findImportFor(
704703
}
705704

706705
// Now look for transitive imports.
707-
auto &importCache = nominal->getASTContext().getImportCache();
706+
auto &importCache = nominalASTCtx.getImportCache();
708707
for (const auto &import : fromSourceFile->getImports()) {
709708
auto &importSet = importCache.getImportSet(import.module.importedModule);
710709
for (const auto &transitive : importSet.getTransitiveImports()) {
@@ -723,7 +722,7 @@ DiagnosticBehavior SendableCheckContext::diagnosticBehavior(
723722
NominalTypeDecl *nominal) const {
724723
// Determine whether this nominal type is visible via a @preconcurrency
725724
// import.
726-
auto import = findImportFor(nominal, fromDC);
725+
auto import = findImportFor(nominal->getParentModule(), nominal->getASTContext(), fromDC);
727726
auto sourceFile = fromDC->getParentSourceFile();
728727

729728
// When the type is explicitly non-Sendable...
@@ -795,7 +794,7 @@ bool swift::diagnoseSendabilityErrorBasedOn(
795794
Optional<AttributedImport<swift::ImportedModule>> import;
796795
SourceFile *sourceFile = fromContext.fromDC->getParentSourceFile();
797796
if (sourceFile) {
798-
import = findImportFor(nominal, fromContext.fromDC);
797+
import = findImportFor(nominal->getParentModule(), nominal->getASTContext(), fromContext.fromDC);
799798
}
800799

801800
// If we found the import that makes this nominal type visible, remark

lib/Sema/TypeCheckConcurrency.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ bool isPotentiallyIsolatedActor(
474474
VarDecl *var, llvm::function_ref<bool(ParamDecl *)> isIsolated =
475475
[](ParamDecl *P) { return P->isIsolated(); });
476476

477+
Optional<AttributedImport<ImportedModule>> findImportFor(
478+
ModuleDecl *nominalModule, ASTContext *nominalASTCtx, const DeclContext *fromDC);
477479
} // end namespace swift
478480

479481
#endif /* SWIFT_SEMA_TYPECHECKCONCURRENCY_H */

0 commit comments

Comments
 (0)