diff --git a/sbt-dotty/sbt-test/sbt-dotty/scala2/build.sbt b/sbt-dotty/sbt-test/sbt-dotty/scala2/build.sbt new file mode 100644 index 000000000000..b96130c4831c --- /dev/null +++ b/sbt-dotty/sbt-test/sbt-dotty/scala2/build.sbt @@ -0,0 +1 @@ +ThisBuild / scalaVersion := "2.12.8" diff --git a/sbt-dotty/sbt-test/sbt-dotty/scala2/project/plugins.sbt b/sbt-dotty/sbt-test/sbt-dotty/scala2/project/plugins.sbt new file mode 100644 index 000000000000..c17caab2d98c --- /dev/null +++ b/sbt-dotty/sbt-test/sbt-dotty/scala2/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version")) diff --git a/sbt-dotty/sbt-test/sbt-dotty/scala2/src/main/scala/hello/Hello.scala b/sbt-dotty/sbt-test/sbt-dotty/scala2/src/main/scala/hello/Hello.scala new file mode 100644 index 000000000000..ea13acf57808 --- /dev/null +++ b/sbt-dotty/sbt-test/sbt-dotty/scala2/src/main/scala/hello/Hello.scala @@ -0,0 +1,7 @@ +package hello +/** Hello, world! */ +object Hello { + def main(args: Array[String]): Unit = { + println("Hello Scala 2") + } +} diff --git a/sbt-dotty/sbt-test/sbt-dotty/scala2/test b/sbt-dotty/sbt-test/sbt-dotty/scala2/test new file mode 100644 index 000000000000..5b197ccda3e2 --- /dev/null +++ b/sbt-dotty/sbt-test/sbt-dotty/scala2/test @@ -0,0 +1,2 @@ +> run +> doc diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala index d1721cdfe65d..fe46f745c459 100644 --- a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala +++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala @@ -142,6 +142,8 @@ object DottyPlugin extends AutoPlugin { } ) + // https://github.com/sbt/sbt/issues/3110 + val Def = sbt.Def override def projectSettings: Seq[Setting[_]] = { Seq( isDotty := scalaVersion.value.startsWith("0."), @@ -293,13 +295,10 @@ object DottyPlugin extends AutoPlugin { allJars ) } - else Def.task { - // This should really be `old` with `val old = scalaInstance.value` - // above, except that this would force the original definition of the - // `scalaInstance` task to be computed when `isDotty` is true, which - // would fail because `managedScalaInstance` is false. - Defaults.scalaInstanceTask.value - } + else + // This dereferences the Initialize graph, but keeps the Task unevaluated, + // so its effect gets fired only when isDotty.value evaluates to false. yay monad. + Def.valueStrict { scalaInstance.taskValue } }.value, // Because managedScalaInstance is false, sbt won't add the standard library to our dependencies for us