sbt/main
Dream 81b81ce6b0
[2.x] fix: Fix consoleProject for Scala 3 (#9073)
**Problem**
consoleProject does not work with Scala 3 because the compiler bridge
does not implement REPL binding injection (scala/scala3#5069).
The bindings currentState, extracted, and cpHelpers are never
injected into the REPL session, causing Not found errors.

**Solution**
Work around the missing binding support by storing the three runtime
objects in a static holder (ConsoleProjectBindings) before launching
the REPL, and generating val definitions via initialCommands that
read from the holder. The original bindings are still passed to
Console to preserve Scala 2 backward compatibility.

Pass -Xrepl-interrupt-instrumentation:local to the REPL when the
consoleProject scala instance is 3.8 or newer. In local mode the
instrumented loader skips re-defining classpath classes and falls
through to standard parent-first delegation, so REPL code sees the
same singleton sbt.* and scala.* classes as the surrounding sbt
process — while still keeping interrupt support for REPL-defined code,
preserving Ctrl+C on long-running expressions like
(Compile / compile).eval.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 01:37:24 -04:00
..
src [2.x] fix: Fix consoleProject for Scala 3 (#9073) 2026-04-16 01:37:24 -04:00
NOTICE Transfer copyright to Scala Center 2023-06-20 16:39:07 +02:00