Skip to content
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

Default to a Scala version for REPL if there are no Scala artifacts. #2431

Merged
merged 2 commits into from
Sep 29, 2023
Merged
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
9 changes: 4 additions & 5 deletions modules/cli/src/main/scala/scala/cli/commands/repl/Repl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,10 @@ object Repl extends ScalaCommand[ReplOptions] {
val cache = options.internal.cache.getOrElse(FileCache())
val shouldUseAmmonite = options.notForBloopOptions.replOptions.useAmmonite

val scalaParams = artifacts.scalaOpt
.getOrElse {
sys.error("Expected Scala artifacts to be fetched")
}
.params
val scalaParams = artifacts.scalaOpt match {
case Some(artifacts) => artifacts.params
case None => ScalaParameters(Constants.defaultScalaVersion)
}

val (scalapyJavaOpts, scalapyExtraEnv) =
if (setupPython) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,21 @@ class ReplTests extends ScalaCliSuite {
expect(output.contains("parser") && output.contains("typer"))
}

test("calling repl with a directory with no scala artifacts") {
val inputs = TestInputs(
os.rel / "Testing.java" -> "public class Testing {}"
)
val cmd = Seq[os.Shellable](
TestUtil.cli,
"repl",
"--repl-dry-run",
"."
)
inputs.fromRoot { root =>
val res = os.proc(cmd)
.call(cwd = root)
expect(res.exitCode == 0)
}
}

}