Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1800,9 +1800,6 @@ SwiftExpressionParser::Parse(DiagnosticManager &diagnostic_manager,
retry = true;
return;
}
// There are no fallback contexts in REPL and playgrounds.
if (repl || playground)
return;
// The fatal error causes a new compiler to be instantiated on retry.
m_swift_ast_ctx.RaiseFatalError(MIE.message());
},
Expand Down
29 changes: 17 additions & 12 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4477,24 +4477,29 @@ SwiftASTContext::GetModule(const SourceModule &module, bool *cached) {
return *module_decl;
}

ThreadSafeASTContext ast = GetASTContext();
if (!ast) {
LOG_PRINTF(GetLog(LLDBLog::Types), "(\"%s\") invalid ASTContext",
module.path.front().GetCString());
swift::ASTContext *raw_ast = nullptr;
{
ThreadSafeASTContext ast = GetASTContext();
if (!ast) {
LOG_PRINTF(GetLog(LLDBLog::Types), "(\"%s\") invalid ASTContext",
module.path.front().GetCString());

return llvm::createStringError("invalid swift::ASTContext");
}
return llvm::createStringError("invalid swift::ASTContext");
}

if (HasFatalErrors()) {
return llvm::createStringError(
llvm::formatv("failed to get module \"{0}\" from AST context:\n"
"AST context is in a fatal error state",
module_name));
if (HasFatalErrors()) {
return llvm::createStringError(
llvm::formatv("failed to get module \"{0}\" from AST context:\n"
"AST context is in a fatal error state",
module_name));
}

raw_ast = *ast;
}

// Create a diagnostic consumer for the diagnostics produced by the import.
auto import_diags = getScopedDiagnosticConsumer();
swift::ModuleDecl *module_decl = ast->getModuleByName(module_name);
swift::ModuleDecl *module_decl = raw_ast->getModuleByName(module_name);

// Error handling.
if (import_diags->HasErrors()) {
Expand Down