diff --git a/lib/AST/Module.cpp b/lib/AST/Module.cpp index 70422d58c781f..1915a78dee61d 100644 --- a/lib/AST/Module.cpp +++ b/lib/AST/Module.cpp @@ -276,8 +276,11 @@ void SourceLookupCache::populateMemberCache(const ModuleDecl &Mod) { "populate-module-class-member-cache"); for (const FileUnit *file : Mod.getFiles()) { - auto &SF = *cast(file); - addToMemberCache(SF.getTopLevelDecls()); + assert(isa(file) || + isa(file)); + SmallVector decls; + file->getTopLevelDecls(decls); + addToMemberCache(decls); } MemberCachePopulated = true; diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp index 46d5307bbd4a0..4d77daf57d5cb 100644 --- a/lib/FrontendTool/FrontendTool.cpp +++ b/lib/FrontendTool/FrontendTool.cpp @@ -1494,9 +1494,19 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance, SerializationOptions serializationOpts = Invocation.computeSerializationOptions(outs, Instance.getMainModule()); + // Infer if this is an emit-module job part of an incremental build, + // vs a partial emit-module job (with primary files) or other kinds. + // We may want to rely on a flag instead to differentiate them. + const bool isEmitModuleSeparately = + Action == FrontendOptions::ActionType::EmitModuleOnly && + MSF.is() && + Instance.getInvocation() + .getTypeCheckerOptions() + .SkipFunctionBodies == FunctionBodySkipping::NonInlinableWithoutTypes; const bool canEmitIncrementalInfoIntoModule = !serializationOpts.DisableCrossModuleIncrementalInfo && - (Action == FrontendOptions::ActionType::MergeModules); + (Action == FrontendOptions::ActionType::MergeModules || + isEmitModuleSeparately); if (canEmitIncrementalInfoIntoModule) { const auto alsoEmitDotFile = Instance.getInvocation()