Skip to content

Fix "sbt console" in Scala 2 projects when sbt-dotty is in the build #6577

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

Merged
merged 2 commits into from
May 29, 2019
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
6 changes: 3 additions & 3 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ object Build {
val referenceVersion = "0.15.0-RC1"

val baseVersion = "0.16.0"
val baseSbtDottyVersion = "0.3.2"
val baseSbtDottyVersion = "0.3.3"

// Versions used by the vscode extension to create a new project
// This should be the latest published releases.
// TODO: Have the vscode extension fetch these numbers from the Internet
// instead of hardcoding them ?
val publishedDottyVersion = "0.13.0-RC1"
val publishedSbtDottyVersion = "0.3.1"
val publishedDottyVersion = referenceVersion
val publishedSbtDottyVersion = "0.3.2"


val dottyOrganization = "ch.epfl.lamp"
Expand Down
15 changes: 15 additions & 0 deletions sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,21 @@ object DottyPlugin extends AutoPlugin {
// bootclasspath, and instead have scala-library and dotty-library on the
// compiler classpath. This means that user code could shadow symbols
// from these jars but we can live with that for now.

// sbt crazy scoping rules mean that when we override `classpathOptions`
// below we also override `classpathOptions in console` which is normally
// set in https://github.com/sbt/sbt/blob/b6f02b9b8cd0abb15e3d8856fd76b570deb1bd61/main/src/main/scala/sbt/Defaults.scala#L503,
// this breaks `sbt console` in Scala 2 projects.
// There seems to be no way to avoid stomping over task-scoped settings,
// so we need to manually set `classpathOptions in console` to something sensible,
// ideally this would be "whatever would be set if this plugin was not enabled",
// but I can't find a way to do this, so we default to whatever is set in ThisBuild.
classpathOptions in console := {
if (isDotty.value)
classpathOptions.value // The Dotty REPL doesn't require anything special on its classpath
else
(classpathOptions in console in ThisBuild).value
},
classpathOptions := {
val old = classpathOptions.value
if (isDotty.value)
Expand Down