diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 5e9500221..b639fa046 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -3594,13 +3594,15 @@ object Classpaths { depSBV <- (dep.project / scalaBinaryVersion).get(data) depCross <- (dep.project / crossVersion).get(data) } yield { - if (isScala2Scala3Sandwich(sbv, depSBV) && depCross == CrossVersion.binary) - depProjId - .withCrossVersion(CrossVersion.constant(depSBV)) - .withConfigurations(dep.configuration) - .withExplicitArtifacts(Vector.empty) - else - depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty) + depCross match { + case b: CrossVersion.Binary if isScala2Scala3Sandwich(sbv, depSBV) => + depProjId + .withCrossVersion(CrossVersion.constant(b.prefix + depSBV)) + .withConfigurations(dep.configuration) + .withExplicitArtifacts(Vector.empty) + case _ => + depProjId.withConfigurations(dep.configuration).withExplicitArtifacts(Vector.empty) + } } } } diff --git a/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/app/src/main/scala/app/Main.scala b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/app/src/main/scala/app/Main.scala new file mode 100644 index 000000000..e3a0fa2ce --- /dev/null +++ b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/app/src/main/scala/app/Main.scala @@ -0,0 +1,9 @@ +package app + +import mylib._ + +object Main { + def main(args: Array[String]): Unit = { + println(MyLib.square(5)) + } +} diff --git a/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/build.sbt b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/build.sbt new file mode 100644 index 000000000..06804de99 --- /dev/null +++ b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/build.sbt @@ -0,0 +1,17 @@ +// TODO use 2.13.4 when it's out +ThisBuild / scalaVersion := "2.13.4-bin-d526da6" + +Global / resolvers += "scala-integration".at("https://scala-ci.typesafe.com/artifactory/scala-integration/") + +lazy val scala3code = project + .enablePlugins(ScalaJSPlugin) + .settings(scalaVersion := "0.27.0-RC1") + +lazy val app = project + .enablePlugins(ScalaJSPlugin) + .dependsOn(scala3code) + .settings( + libraryDependencies ~= (_.filterNot(_.name.contains("scalajs-compiler"))), + addCompilerPlugin("org.scala-js" % "scalajs-compiler_2.13.3" % scalaJSVersion), + scalaJSUseMainModuleInitializer := true, + ) diff --git a/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/project/plugins.sbt b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/project/plugins.sbt new file mode 100644 index 000000000..289edbdba --- /dev/null +++ b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/project/plugins.sbt @@ -0,0 +1,2 @@ +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.3") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0") diff --git a/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/scala3code/src/main/scala/mylib/MyLib.scala b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/scala3code/src/main/scala/mylib/MyLib.scala new file mode 100644 index 000000000..ae2f3af75 --- /dev/null +++ b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/scala3code/src/main/scala/mylib/MyLib.scala @@ -0,0 +1,5 @@ +package mylib + +object MyLib { + def square(x: Int): Int = x * x +} diff --git a/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/test b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/test new file mode 100644 index 000000000..63092ffa4 --- /dev/null +++ b/sbt/src/sbt-test/plugins/dotty-sandwich-sjs/test @@ -0,0 +1 @@ +> app/run