Skip to content

Commit 1e5be2b

Browse files
authored
Merge pull request #78046 from nkcsgexi/140818215
FineModuleTrace: avoid emitting trace file when lazy type checking is enabled.
2 parents 2914d0e + 5deb21d commit 1e5be2b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/FrontendTool/LoadedModuleTrace.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,10 @@ static void createFineModuleTraceFile(const InputFile &input, ModuleDecl *MD) {
917917

918918
bool swift::emitFineModuleTraceIfNeeded(ModuleDecl *mainModule,
919919
const FrontendOptions &opts) {
920+
// When lazy type checking is enabled, we may end up with a partial AST.
921+
// Walking on these partial AST completely may expose latent bugs.
922+
if (mainModule->getASTContext().TypeCheckerOpts.EnableLazyTypecheck)
923+
return false;
920924
ASTContext &ctxt = mainModule->getASTContext();
921925
assert(!ctxt.hadError() &&
922926
"We should've already exited earlier if there was an error.");

test/IDE/objc_send_collector_1.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// RUN: SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH=%t/given_trace.json %target-swift-frontend -I %t/lib/swift -typecheck %s %S/Inputs/objc_send_collector_2.swift -module-name main -swift-version 5 -F %S/Inputs/mock-sdk -emit-loaded-module-trace-path %t/.MODULE_TRACE
88
// RUN: cat %t/given_trace.json | %{python} -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' | %FileCheck %s
99

10+
// RUN: SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH=%t/given_trace_2.json %target-swift-frontend -I %t/lib/swift -typecheck %s %S/Inputs/objc_send_collector_2.swift -module-name main -swift-version 5 -F %S/Inputs/mock-sdk -emit-loaded-module-trace-path %t/.MODULE_TRACE -enable-library-evolution -experimental-lazy-typecheck
11+
// RUN: not ls %t/given_trace_2.json
12+
1013
// REQUIRES: objc_interop
1114

1215
import Foo

0 commit comments

Comments
 (0)