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(
929929 SourceFile &MainFile =
930930 MainModule->getMainSourceFile (Invocation.getSourceFileKind ());
931931
932- auto &Diags = MainFile.getASTContext ().Diags ;
933- auto DidSuppressWarnings = Diags.getSuppressWarnings ();
934- Diags.setSuppressWarnings (DidSuppressWarnings || !mainIsPrimary);
935-
936932 // For a primary, perform type checking if needed. Otherwise, just do import
937933 // resolution.
938934 if (mainIsPrimary && LimitStage >= SourceFile::TypeChecked) {
@@ -948,8 +944,6 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo(
948944 parseSourceFileSIL (MainFile, &SILContext);
949945 }
950946
951- Diags.setSuppressWarnings (DidSuppressWarnings);
952-
953947 if (mainIsPrimary && !Context->hadError () &&
954948 Invocation.getFrontendOptions ().DebuggerTestingTransform ) {
955949 performDebuggerTestingTransform (MainFile);
Original file line number Diff line number Diff line change @@ -282,6 +282,17 @@ void swift::performImportResolution(SourceFile &SF) {
282282
283283 FrontendStatsTracer tracer (SF.getASTContext ().Stats ,
284284 " 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+
285296 ImportResolver resolver (SF);
286297
287298 // Resolve each import declaration.
You can’t perform that action at this time.
0 commit comments