Skip to content

Commit 04c842a

Browse files
committed
Test compiling with TASTy of stdlib-bootstrapped
1 parent 5213b9e commit 04c842a

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134

135135
- name: Cmd Tests
136136
run: |
137-
./project/scripts/sbt ";dist/pack; scala3-bootstrapped/compile; scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test"
137+
./project/scripts/sbt ";dist/pack; scala3-bootstrapped/compile; scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped-tasty-tests/run ;stdlib-bootstrapped-tasty-tests/test; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test"
138138
./project/scripts/cmdTests
139139
./project/scripts/bootstrappedOnlyCmdTests
140140
@@ -488,7 +488,7 @@ jobs:
488488

489489
- name: Test
490490
run: |
491-
./project/scripts/sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped/test:run ;stdlib-bootstrapped-tasty-tests/test"
491+
./project/scripts/sbt ";dist/pack ;scala3-bootstrapped/compile ;scala3-bootstrapped/test ;sbt-test/scripted scala2-compat/* ;stdlib-bootstrapped-tasty-tests/run ;stdlib-bootstrapped-tasty-tests/test"
492492
./project/scripts/cmdTests
493493
./project/scripts/bootstrappedOnlyCmdTests
494494

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ val `scala3-bench` = Build.`scala3-bench`
1515
val `scala3-bench-bootstrapped` = Build.`scala3-bench-bootstrapped`
1616
val `scala3-bench-micro` = Build.`scala3-bench-micro`
1717
val `stdlib-bootstrapped` = Build.`stdlib-bootstrapped`
18+
val `stdlib-bootstrapped-tasty` = Build.`stdlib-bootstrapped-tasty`
1819
val `stdlib-bootstrapped-tasty-tests` = Build.`stdlib-bootstrapped-tasty-tests`
1920
val `tasty-core` = Build.`tasty-core`
2021
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`

project/Build.scala

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ object Build {
931931
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
932932
settings(commonBootstrappedSettings).
933933
settings(
934-
moduleName := "scala-library",
934+
moduleName := "scala2-library",
935935
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
936936
Compile / scalacOptions ++= {
937937
Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString)
@@ -994,13 +994,27 @@ object Build {
994994
"scala.annotation.specialized",
995995
"scala.annotation.unspecialized",
996996
),
997-
// TODO package only TASTy files.
998-
// We first need to check that a project can depend on a JAR that only contains TASTy files.
999-
// Compile / exportJars := true,
1000-
// Compile / packageBin / mappings ~= { _.filter(_._2.endsWith(".tasty")) },
997+
Compile / exportJars := true,
998+
artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
999+
"scala2-library-" + dottyVersion + "." + artifact.extension
1000+
}
1001+
)
1002+
1003+
/** Packages the TASTy files of `stdlib-bootstrapped` in a jar */
1004+
lazy val `stdlib-bootstrapped-tasty` = project.in(file("stdlib-bootstrapped-tasty")).
1005+
withCommonSettings(Bootstrapped).
1006+
settings(
1007+
exportJars := true,
1008+
Compile / packageBin / mappings := {
1009+
(`stdlib-bootstrapped` / Compile / packageBin / mappings).value
1010+
.filter(_._2.endsWith(".tasty"))
1011+
},
10011012
)
10021013

10031014
/** Test the tasty generated by `stdlib-bootstrapped`
1015+
*
1016+
* The sources in src are compiled using TASTy from stdlib-bootstrapped-tasty but then run
1017+
* with the scala-library compiled be Scala 2.
10041018
*
10051019
* The tests are run with the bootstrapped compiler and the tasty inpector on the classpath.
10061020
* The classpath has the default `scala-library` and not `stdlib-bootstrapped`.
@@ -1011,11 +1025,23 @@ object Build {
10111025
*/
10121026
lazy val `stdlib-bootstrapped-tasty-tests` = project.in(file("stdlib-bootstrapped-tasty-tests")).
10131027
withCommonSettings(Bootstrapped).
1028+
dependsOn(dottyCompiler(Bootstrapped) % "compile->compile").
10141029
dependsOn(`scala3-tasty-inspector` % "test->test").
1030+
dependsOn(`stdlib-bootstrapped-tasty`).
10151031
settings(commonBootstrappedSettings).
10161032
settings(
10171033
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
1018-
javaOptions += "-Ddotty.scala.library=" + (`stdlib-bootstrapped` / Compile / packageBin).value.getAbsolutePath
1034+
Test / javaOptions += "-Ddotty.scala.library=" + (`stdlib-bootstrapped` / Compile / packageBin).value.getAbsolutePath,
1035+
Compile / compile / fullClasspath ~= {
1036+
_.filterNot(file => file.data.getName == s"scala-library-${stdlibVersion(Bootstrapped)}.jar")
1037+
},
1038+
Compile / compile / dependencyClasspath := {
1039+
// make sure that the scala2-library (tasty of `stdlib-bootstrapped-tasty`) is listed before the scala-library (classfiles)
1040+
val (bootstrappedLib, otherLibs) =
1041+
(Compile / compile / dependencyClasspath).value
1042+
.partition(_.data.getName == s"scala2-library-${dottyVersion}.jar")
1043+
bootstrappedLib ++ otherLibs
1044+
},
10191045
)
10201046

10211047
lazy val `scala3-sbt-bridge` = project.in(file("sbt-bridge/src")).

stdlib-bootstrapped/test/Main.scala renamed to stdlib-bootstrapped-tasty-tests/src/Main.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ object HelloWorld:
3535
def testScala2ProductMembers() = {
3636
Some(1)._1
3737
Right(1)._1
38-
(1, 2)._1
39-
(1, 2)._2
38+
// (1, 2)._1 // FIXME: Exception java.lang.IncompatibleClassChangeError: class scala.Tuple2$mcII$sp cannot inherit from final class scala.Tuple2
39+
// (1, 2)._2 // FIXME: Exception java.lang.IncompatibleClassChangeError: class scala.Tuple2$mcII$sp cannot inherit from final class scala.Tuple2
4040
::(1, Nil)._1
4141
::(1, Nil)._2
4242
}

0 commit comments

Comments
 (0)