File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -929,10 +929,6 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo(
929
929
SourceFile &MainFile =
930
930
MainModule->getMainSourceFile (Invocation.getSourceFileKind ());
931
931
932
- auto &Diags = MainFile.getASTContext ().Diags ;
933
- auto DidSuppressWarnings = Diags.getSuppressWarnings ();
934
- Diags.setSuppressWarnings (DidSuppressWarnings || !mainIsPrimary);
935
-
936
932
// For a primary, perform type checking if needed. Otherwise, just do import
937
933
// resolution.
938
934
if (mainIsPrimary && LimitStage >= SourceFile::TypeChecked) {
@@ -948,8 +944,6 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo(
948
944
parseSourceFileSIL (MainFile, &SILContext);
949
945
}
950
946
951
- Diags.setSuppressWarnings (DidSuppressWarnings);
952
-
953
947
if (mainIsPrimary && !Context->hadError () &&
954
948
Invocation.getFrontendOptions ().DebuggerTestingTransform ) {
955
949
performDebuggerTestingTransform (MainFile);
Original file line number Diff line number Diff line change @@ -282,6 +282,17 @@ void swift::performImportResolution(SourceFile &SF) {
282
282
283
283
FrontendStatsTracer tracer (SF.getASTContext ().Stats ,
284
284
" Import resolution" );
285
+
286
+ // If we're silencing parsing warnings, then also silence import warnings.
287
+ // This is necessary for secondary files as they can be parsed and have their
288
+ // imports resolved multiple times.
289
+ auto &diags = SF.getASTContext ().Diags ;
290
+ auto didSuppressWarnings = diags.getSuppressWarnings ();
291
+ auto shouldSuppress = SF.getParsingOptions ().contains (
292
+ SourceFile::ParsingFlags::SuppressWarnings);
293
+ diags.setSuppressWarnings (didSuppressWarnings || shouldSuppress);
294
+ SWIFT_DEFER { diags.setSuppressWarnings (didSuppressWarnings); };
295
+
285
296
ImportResolver resolver (SF);
286
297
287
298
// Resolve each import declaration.
You can’t perform that action at this time.
0 commit comments