@@ -721,25 +721,28 @@ bool SwiftUserExpression::Parse(DiagnosticManager &diagnostic_manager,
721721 return error (" couldn't start parsing - no stack frame" );
722722
723723 ExecutionContextScope *exe_scope =
724- m_options.GetREPLEnabled () ? static_cast <ExecutionContextScope *>(target)
725- : static_cast <ExecutionContextScope *>(frame);
724+ m_options.GetREPLEnabled () || m_options.GetPlaygroundTransformEnabled ()
725+ ? static_cast <ExecutionContextScope *>(target)
726+ : static_cast <ExecutionContextScope *>(frame);
726727
727- exe_scope = exe_ctx.GetBestExecutionContextScope ();
728+ exe_scope = exe_ctx.GetBestExecutionContextScope ();
728729
729- m_swift_scratch_ctx = target->GetSwiftScratchContext (m_err, *exe_scope);
730+ m_swift_scratch_ctx = target->GetSwiftScratchContext (
731+ m_err, *exe_scope, /* create_on_demand=*/ true ,
732+ m_options.GetPlaygroundTransformEnabled ());
730733 if (!m_swift_scratch_ctx)
731734 return error (" could not create a Swift scratch context: " ,
732735 m_err.AsCString ());
733736
734737 // For playgrounds, the target triple should be used for expression
735738 // evaluation, not the current module. This requires disabling precise
736739 // compiler invocations.
737- //
738- // To disable precise compiler invocations, pass a null SymbolContext.
739- const SymbolContext * sc = nullptr ;
740- if (!m_runs_in_playground_or_repl)
741- sc = &frame-> GetSymbolContext (lldb::eSymbolContextFunction);
742-
740+ SymbolContext sc;
741+ if (m_options. GetREPLEnabled () || m_options. GetPlaygroundTransformEnabled ())
742+ sc = SymbolContext (target-> shared_from_this (),
743+ target-> GetExecutableModule ());
744+ else
745+ sc = frame-> GetSymbolContext (lldb::eSymbolContextFunction);
743746 auto *swift_ast_ctx = m_swift_scratch_ctx->get ()->GetSwiftASTContext (sc);
744747 m_swift_ast_ctx =
745748 llvm::dyn_cast_or_null<SwiftASTContextForExpressions>(swift_ast_ctx);
0 commit comments