Skip to content

REPL: extract into separate subproject #18536

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

Closed
wants to merge 12 commits into from

Conversation

mpollmeier
Copy link
Contributor

Currently the REPL implementation is part of the scala3-compiler project. This PR extracts it into a separate scala3-repl project which helps to separate concerns. Main benefits:

  1. Trim dependency tree for scala3-compiler: jline-reader, jline-terminal and jline-terminal-jna are currently direct dependencies of scala3-compiler (see https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/3.3.1/scala3-compiler_3-3.3.1.pom). This PR moves those down to scala3-repl, which helps all downstream builds as well.

  2. Simplify future REPL improvements by isolating the REPL code (which contributors might be less afraid to touch) from the core compiler code.

Implementation note 1: I moved the MainGeneric* into dist - not sure if that's the most elegant solution to ensure we have a single runner/compiler for everything.

Implementation note 2: not sure if scaladoc really needs the dist and repl jars in it's classpath.

n.b. the original idea came up in #17624

@mpollmeier
Copy link
Contributor Author

I guess I need some help to greenify the test setup. But before we sink any additional time into that, a general review of the proposed changes would be great 🙇🏻

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the fence on this. I like the idea of avoiding parts of the compiler accidentally depending on jline or other REPL dependencies. But I'm not sure about introducing two new jars to do it. So then we could imitate Scala 2 and have separate projects but ship it all as 1 jar - but is that build complication worth it? Perhaps Scala 2 is precedent for yes...

status: there's a few places where scala3-compiler uses the repl
directly:

```
[error] -- [E006] Not Found Error: /home/mp/Projects/dotty/compiler/src/dotty/tools/MainGenericCompiler.scala:181:8
[error] 181 |        repl.Main.main(properArgs.toArray)
[error]     |        ^^^^
[error]     |        Not found: repl
[error]     |
[error]     | longer explanation available when compiling with `-explain`
[error] -- [E006] Not Found Error: /home/mp/Projects/dotty/compiler/src/dotty/tools/MainGenericRunner.scala:193:8
[error] 193 |        repl.Main.main(properArgs.toArray)
[error]     |        ^^^^
[error]     |        Not found: repl
[error]     |
[error]     | longer explanation available when compiling with `-explain`
[error] -- [E008] Not Found Error: /home/mp/Projects/dotty/compiler/src/dotty/tools/dotc/quoted/Interpreter.scala:30:19
[error] 30 |import dotty.tools.repl.AbstractFileClassLoader
[error]    |       ^^^^^^^^^^^^^^^^
[error]    |       value repl is not a member of dotty.tools
[error] -- [E008] Not Found Error: /home/mp/Projects/dotty/compiler/src/dotty/tools/dotc/util/ClasspathFromClassloader.scala:8:19
[error] 8 |import dotty.tools.repl.AbstractFileClassLoader
[error]   |       ^^^^^^^^^^^^^^^^
[error]   |       value repl is not a member of dotty.tools
[error] four errors found
[error] (scala3-compiler / Compile / compileIncremental) Compilation failed
```
there doesn't seem to be anything repl-specific about it, and it's used in a few places
in the compiler
@mpollmeier mpollmeier force-pushed the repl/extract-to-subproject2 branch from 55109f7 to 6d675ad Compare September 14, 2023 11:25
@mpollmeier
Copy link
Contributor Author

Thanks for the feedback!
It's factored in and I just rebased the branch.

@dwijnand
Copy link
Member

dwijnand commented Feb 1, 2024

I don't think we should create a dist jar. And, on balance, I don't think the benefits mentioned from this change are worth the efforts and risks of making the change.

@lrytz
Copy link
Member

lrytz commented Feb 1, 2024

A separate scala-repl artifact will require changes to build tools, I'm not sure where exactly. Possibly in coursier, somewhere it's defined that a Scala compiler instance has scala3-compiler and its dependencies. If that no longer includes the REPL the console task in sbt won't work.

@mpollmeier
Copy link
Contributor Author

Alright. Thanks for taking the time and mental cycles to consider this proposal!

@mpollmeier mpollmeier closed this Feb 1, 2024
@lrytz
Copy link
Member

lrytz commented Feb 1, 2024

(I didn't mean to push back as I didn't review the change, I just wanted to point out this consequence.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants