From d46235bc79fbdd0d31d8dbfbbab955ecedea05eb Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 28 May 2019 16:15:50 +0200 Subject: [PATCH 1/2] Fix "sbt console" in Scala 2 projects when sbt-dotty is in the build See https://github.com/scala/scala-xml/issues/313 for example. No test because apparently there's no way to properly test "sbt console" from scripted tests: https://github.com/sbt/sbt/blob/b6f02b9b8cd0abb15e3d8856fd76b570deb1bd61/sbt/src/sbt-test/project/console/test#L7 --- .../src/dotty/tools/sbtplugin/DottyPlugin.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala index 9408bbdcb3c0..0386075dd116 100644 --- a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala +++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala @@ -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) From eb7ef9bbd66f0a8458024245cd57770b8d9f9bad Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 29 May 2019 14:22:14 +0200 Subject: [PATCH 2/2] sbt-dotty: Bump to 0.3.3-SNAPSHOT --- project/Build.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 8474b9c8690a..1e3f4ec7fc5a 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -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"