diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 56b0b7457f83..046153a8d54b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,7 +93,7 @@ jobs: - name: Test run: | - ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test;sjsSandbox/run;sjsSandbox/test;sjsJUnitTests/test;sjsCompilerTests/test ;configureIDE" + ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test;sjsSandbox/run;sjsSandbox/test;sjsJUnitTests/test;sjsCompilerTests/test ;scala2-interop-tests/scripted ;configureIDE" ./project/scripts/bootstrapCmdTests diff --git a/build.sbt b/build.sbt index 28559cb1c4a9..eee30e51036f 100644 --- a/build.sbt +++ b/build.sbt @@ -27,6 +27,7 @@ val `scala-reflect` = Build.`scala-reflect` val scalap = Build.scalap val dist = Build.dist val `community-build` = Build.`community-build` +val `scala2-interop-tests` = Build.`scala2-interop-tests` val sjsSandbox = Build.sjsSandbox val sjsJUnitTests = Build.sjsJUnitTests diff --git a/project/Build.scala b/project/Build.scala index 10a29512152e..76fd7f5d4378 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1126,6 +1126,39 @@ object Build { libraryDependencies := Seq("org.scala-lang" % "scalap" % stdlibVersion(Bootstrapped)) ) + lazy val `scala2-interop-tests` = project.in(file("tests/scala2-interop")). + enablePlugins(SbtPlugin). + settings(commonSettings). + settings( + sbtTestDirectory := baseDirectory.value / "sbt-test", + scriptedLaunchOpts ++= Seq( + "-Dplugin.version=" + sbtDottyVersion, + "-Dplugin.scalaVersion=" + dottyVersion, + "-Dplugin.scala2Version=" + stdlibVersion(Bootstrapped), + "-Dsbt.boot.directory=" + ((baseDirectory in ThisBuild).value / ".sbt-scripted").getAbsolutePath // Workaround sbt/sbt#3469 + ), + // Pass along ivy home and repositories settings to sbt instances run from the tests + scriptedLaunchOpts ++= { + val repositoryPath = (io.Path.userHome / ".sbt" / "repositories").absolutePath + s"-Dsbt.repository.config=$repositoryPath" :: + ivyPaths.value.ivyHome.map("-Dsbt.ivy.home=" + _.getAbsolutePath).toList + }, + scriptedBufferLog := true, + scripted := scripted.dependsOn( + publishLocal in `dotty-sbt-bridge`, + publishLocal in `dotty-interfaces`, + publishLocal in `dotty-compiler-bootstrapped`, + publishLocal in `dotty-library-bootstrapped`, + publishLocal in `dotty-library-bootstrappedJS`, + publishLocal in `tasty-core-bootstrapped`, + publishLocal in `dotty-tasty-inspector`, + publishLocal in `scala-library`, + publishLocal in `scala-reflect`, + publishLocal in `dotty-doc-bootstrapped`, + publishLocal in `dotty-bootstrapped`, + publishLocal in `sbt-dotty` + ).evaluated + ) // sbt plugin to use Dotty in your own build, see // https://github.com/lampepfl/dotty-example-project for usage. diff --git a/sbt-dotty/sbt-test/scala2-compat/akka/build.sbt b/tests/scala2-interop/sbt-test/3rdparty/akka/build.sbt similarity index 100% rename from sbt-dotty/sbt-test/scala2-compat/akka/build.sbt rename to tests/scala2-interop/sbt-test/3rdparty/akka/build.sbt diff --git a/sbt-dotty/sbt-test/scala2-compat/akka/i3100.scala b/tests/scala2-interop/sbt-test/3rdparty/akka/i3100.scala similarity index 100% rename from sbt-dotty/sbt-test/scala2-compat/akka/i3100.scala rename to tests/scala2-interop/sbt-test/3rdparty/akka/i3100.scala diff --git a/sbt-dotty/sbt-test/scala2-compat/akka/project/plugins.sbt b/tests/scala2-interop/sbt-test/3rdparty/akka/project/plugins.sbt similarity index 100% rename from sbt-dotty/sbt-test/scala2-compat/akka/project/plugins.sbt rename to tests/scala2-interop/sbt-test/3rdparty/akka/project/plugins.sbt diff --git a/sbt-dotty/sbt-test/scala2-compat/akka/test b/tests/scala2-interop/sbt-test/3rdparty/akka/test similarity index 100% rename from sbt-dotty/sbt-test/scala2-compat/akka/test rename to tests/scala2-interop/sbt-test/3rdparty/akka/test diff --git a/sbt-dotty/sbt-test/scala2-compat/eff/build.sbt b/tests/scala2-interop/sbt-test/3rdparty/eff/build.sbt similarity index 100% rename from sbt-dotty/sbt-test/scala2-compat/eff/build.sbt rename to tests/scala2-interop/sbt-test/3rdparty/eff/build.sbt diff --git a/sbt-dotty/sbt-test/scala2-compat/eff/i6484.scala b/tests/scala2-interop/sbt-test/3rdparty/eff/i6484.scala similarity index 100% rename from sbt-dotty/sbt-test/scala2-compat/eff/i6484.scala rename to tests/scala2-interop/sbt-test/3rdparty/eff/i6484.scala diff --git a/sbt-dotty/sbt-test/scala2-compat/eff/project/plugins.sbt b/tests/scala2-interop/sbt-test/3rdparty/eff/project/plugins.sbt similarity index 100% rename from sbt-dotty/sbt-test/scala2-compat/eff/project/plugins.sbt rename to tests/scala2-interop/sbt-test/3rdparty/eff/project/plugins.sbt diff --git a/sbt-dotty/sbt-test/scala2-compat/eff/test b/tests/scala2-interop/sbt-test/3rdparty/eff/test similarity index 100% rename from sbt-dotty/sbt-test/scala2-compat/eff/test rename to tests/scala2-interop/sbt-test/3rdparty/eff/test diff --git a/tests/scala2-interop/sbt-test/3rdparty/finagle/build.sbt b/tests/scala2-interop/sbt-test/3rdparty/finagle/build.sbt new file mode 100644 index 000000000000..a3c28b3d6943 --- /dev/null +++ b/tests/scala2-interop/sbt-test/3rdparty/finagle/build.sbt @@ -0,0 +1,4 @@ +scalaVersion := sys.props("plugin.scalaVersion") + +libraryDependencies += + ("com.twitter" %% "finagle-core" % "20.9.0").withDottyCompat(scalaVersion.value) diff --git a/tests/scala2-interop/sbt-test/3rdparty/finagle/i9916.scala b/tests/scala2-interop/sbt-test/3rdparty/finagle/i9916.scala new file mode 100644 index 000000000000..7c692f529428 --- /dev/null +++ b/tests/scala2-interop/sbt-test/3rdparty/finagle/i9916.scala @@ -0,0 +1,10 @@ +import com.twitter.finagle.Stack +import com.twitter.finagle.liveness.FailureAccrualFactory + +trait T { + def p: FailureAccrualFactory.Param +} + +class A { + val t = Stack.Param[FailureAccrualFactory.Param](FailureAccrualFactory.Param(???)) +} diff --git a/tests/scala2-interop/sbt-test/3rdparty/finagle/pending b/tests/scala2-interop/sbt-test/3rdparty/finagle/pending new file mode 100644 index 000000000000..5df2af1f3956 --- /dev/null +++ b/tests/scala2-interop/sbt-test/3rdparty/finagle/pending @@ -0,0 +1 @@ +> compile diff --git a/tests/scala2-interop/sbt-test/3rdparty/finagle/project/plugins.sbt b/tests/scala2-interop/sbt-test/3rdparty/finagle/project/plugins.sbt new file mode 100644 index 000000000000..c17caab2d98c --- /dev/null +++ b/tests/scala2-interop/sbt-test/3rdparty/finagle/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version")) diff --git a/tests/scala2-interop/sbt-test/pos/i9916a/build.sbt b/tests/scala2-interop/sbt-test/pos/i9916a/build.sbt new file mode 100644 index 000000000000..32ec1fc1cc63 --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916a/build.sbt @@ -0,0 +1,15 @@ +val scala3Version = sys.props("plugin.scalaVersion") +val scala2Version = sys.props("plugin.scala2Version") + +lazy val `i9916a-lib` = (project in file ("lib")) + .settings(scalaVersion := scala2Version) + +lazy val `i9916a-test` = (project in file ("main")) + .dependsOn(`i9916a-lib`) + .settings( + scalaVersion := scala3Version, + // https://github.com/sbt/sbt/issues/5369 + projectDependencies := { + projectDependencies.value.map(_.withDottyCompat(scalaVersion.value)) + } + ) diff --git a/tests/scala2-interop/sbt-test/pos/i9916a/lib/i9916a-lib.scala b/tests/scala2-interop/sbt-test/pos/i9916a/lib/i9916a-lib.scala new file mode 100644 index 000000000000..44882333a2f5 --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916a/lib/i9916a-lib.scala @@ -0,0 +1,7 @@ +package i9916a + +object Lib { + trait P + object P + def P(x: Int): P = ??? +} diff --git a/tests/scala2-interop/sbt-test/pos/i9916a/main/i9916a-test.scala b/tests/scala2-interop/sbt-test/pos/i9916a/main/i9916a-test.scala new file mode 100644 index 000000000000..1b10c3504ca7 --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916a/main/i9916a-test.scala @@ -0,0 +1,5 @@ +import i9916a.Lib + +trait Test { + def foo: Lib.P +} diff --git a/tests/scala2-interop/sbt-test/pos/i9916a/pending b/tests/scala2-interop/sbt-test/pos/i9916a/pending new file mode 100644 index 000000000000..2a848354ed12 --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916a/pending @@ -0,0 +1 @@ +> i9916a-test/compile diff --git a/tests/scala2-interop/sbt-test/pos/i9916a/project/plugins.sbt b/tests/scala2-interop/sbt-test/pos/i9916a/project/plugins.sbt new file mode 100644 index 000000000000..c17caab2d98c --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916a/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version")) diff --git a/tests/scala2-interop/sbt-test/pos/i9916b/build.sbt b/tests/scala2-interop/sbt-test/pos/i9916b/build.sbt new file mode 100644 index 000000000000..f789fd0860b8 --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916b/build.sbt @@ -0,0 +1,15 @@ +val scala3Version = sys.props("plugin.scalaVersion") +val scala2Version = sys.props("plugin.scala2Version") + +lazy val `i9916b-lib` = (project in file ("lib")) + .settings(scalaVersion := scala2Version) + +lazy val `i9916b-test` = (project in file ("main")) + .dependsOn(`i9916b-lib`) + .settings( + scalaVersion := scala3Version, + // https://github.com/sbt/sbt/issues/5369 + projectDependencies := { + projectDependencies.value.map(_.withDottyCompat(scalaVersion.value)) + } + ) diff --git a/tests/scala2-interop/sbt-test/pos/i9916b/lib/i9916b-lib.scala b/tests/scala2-interop/sbt-test/pos/i9916b/lib/i9916b-lib.scala new file mode 100644 index 000000000000..0ce017246f86 --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916b/lib/i9916b-lib.scala @@ -0,0 +1,7 @@ +package i9916b + +trait T { + class A + object A + def A(x: Int): Unit = ??? +} diff --git a/tests/scala2-interop/sbt-test/pos/i9916b/main/i9916b-test.scala b/tests/scala2-interop/sbt-test/pos/i9916b/main/i9916b-test.scala new file mode 100644 index 000000000000..fb702d1a8617 --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916b/main/i9916b-test.scala @@ -0,0 +1,5 @@ +import i9916b.T + +trait Test { + def foo: T +} diff --git a/tests/scala2-interop/sbt-test/pos/i9916b/project/plugins.sbt b/tests/scala2-interop/sbt-test/pos/i9916b/project/plugins.sbt new file mode 100644 index 000000000000..c17caab2d98c --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916b/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version")) diff --git a/tests/scala2-interop/sbt-test/pos/i9916b/test b/tests/scala2-interop/sbt-test/pos/i9916b/test new file mode 100644 index 000000000000..064736132510 --- /dev/null +++ b/tests/scala2-interop/sbt-test/pos/i9916b/test @@ -0,0 +1 @@ +> i9916b-test/compile