-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support //> using dep "..."
directives in Scala REPL
#24131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
// Update both compiler classpath and classloader | ||
val prevOutputDir = ctx.settings.outputDir.value | ||
val prevClassLoader = rendering.classLoader() | ||
rendering.myClassLoader = DependencyResolver.addToCompilerClasspath( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nod to just a nod to #24119 which has sensitive state towards whatever the current classloader is.
The failure looks like a network flake |
I think we should extract the repl to be its own artifact before accepting this change. @Gedochao lets add splitting the repl from the compiler to next week's core. |
It makes a great deal of architectural sense for the REPL to be its own artifact. The REPL is conceptually separate, and most consumers of the compiler don't consume the REPL. (Making the separation in Scala 2 was a long term goal of @adriaanm's that he did a great deal of work on, but we just never got it over the finish line.) |
We will explore making REPL its own artifact, in which case the approach from this PR could work. |
Since this isn't a language feature, presumably we can introduce it anytime? It's only for interactive use so there's no backwards compatibility concerns |
This PR is a proof-of-concept implementation porting over the Ammonite
import $ivy
functionality to the Scala REPL, using the Scala-CLIusing dep
syntax. Once this lands, along with other related PRs (#24127, #23849) we can probably deprecate Ammonite and refer people to the main Scala REPL since it'll have acquired all the important featuresTested manually:
Both
io.get-coursier:interface
andorg.virtuslab:using_directives
are zero-dependency Java libraries, and so can be used directly without worrying about binary compatibility. Both libraries are widely used in the Scala ecosystem (SBT, Mill, ScalaCLI, Bazel, ...) and should be pretty trustworthy and reliableNot sure if we want to put this into the compiler codebase, but that's where the REPL logic currently lives, and I figure anyone working on the compiler may find it useful as well. e.g. You can pull in third-party libraries when working in the REPL to see how a new language feature interacts with an existing library.
We can move the logic out of the compiler codebase if we want, but as a first pass this integration seems relatively straightforward. The "correct" way of re-organizing this would be to split the
dotty.tools.repl
into a separate subproject from the rest ofcompiler
so programmatic non-REPL use cases (e.g. build tools) don't need to pull it in, but that would be a larger refactor beyond the scope of this PR