Skip to content

Commit 37c3aa3

Browse files
authored
Merge pull request #6577 from dotty-staging/sbt-dotty-interference
Fix "sbt console" in Scala 2 projects when sbt-dotty is in the build
2 parents 0dc2172 + eb7ef9b commit 37c3aa3

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

project/Build.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ object Build {
6262
val referenceVersion = "0.15.0-RC1"
6363

6464
val baseVersion = "0.16.0"
65-
val baseSbtDottyVersion = "0.3.2"
65+
val baseSbtDottyVersion = "0.3.3"
6666

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

7474

7575
val dottyOrganization = "ch.epfl.lamp"

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,21 @@ object DottyPlugin extends AutoPlugin {
234234
// bootclasspath, and instead have scala-library and dotty-library on the
235235
// compiler classpath. This means that user code could shadow symbols
236236
// from these jars but we can live with that for now.
237+
238+
// sbt crazy scoping rules mean that when we override `classpathOptions`
239+
// below we also override `classpathOptions in console` which is normally
240+
// set in https://github.com/sbt/sbt/blob/b6f02b9b8cd0abb15e3d8856fd76b570deb1bd61/main/src/main/scala/sbt/Defaults.scala#L503,
241+
// this breaks `sbt console` in Scala 2 projects.
242+
// There seems to be no way to avoid stomping over task-scoped settings,
243+
// so we need to manually set `classpathOptions in console` to something sensible,
244+
// ideally this would be "whatever would be set if this plugin was not enabled",
245+
// but I can't find a way to do this, so we default to whatever is set in ThisBuild.
246+
classpathOptions in console := {
247+
if (isDotty.value)
248+
classpathOptions.value // The Dotty REPL doesn't require anything special on its classpath
249+
else
250+
(classpathOptions in console in ThisBuild).value
251+
},
237252
classpathOptions := {
238253
val old = classpathOptions.value
239254
if (isDotty.value)

0 commit comments

Comments
 (0)