Skip to content

Commit 24472ff

Browse files
committed
Replace stdlib-bootstrapped with stdlib-2_13-bootstrapped
1 parent 52bf33e commit 24472ff

File tree

5 files changed

+57
-126
lines changed

5 files changed

+57
-126
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 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-2_13-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/test:run ;stdlib-bootstrapped-tasty-tests/test; scala3-compiler-bootstrapped/scala3CompilerCoursierTest:test"
138138
./project/scripts/cmdTests
139139
./project/scripts/bootstrappedOnlyCmdTests
140140
@@ -253,7 +253,7 @@ jobs:
253253

254254
- name: MiMa
255255
run: |
256-
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues; stdlib-2_13-bootstrapped/mimaReportBinaryIssues"
256+
./project/scripts/sbt ";scala3-interfaces/mimaReportBinaryIssues ;scala3-library-bootstrapped/mimaReportBinaryIssues ;scala3-library-bootstrappedJS/mimaReportBinaryIssues; tasty-core-bootstrapped/mimaReportBinaryIssues; stdlib-bootstrapped/mimaReportBinaryIssues"
257257
258258
community_build_a:
259259
runs-on: [self-hosted, Linux]
@@ -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-2_13-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/test:run ;stdlib-bootstrapped-tasty-tests/test"
492492
./project/scripts/cmdTests
493493
./project/scripts/bootstrappedOnlyCmdTests
494494

build.sbt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ 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-2_13-bootstrapped` = Build.`stdlib-2_13-bootstrapped`
1918
val `stdlib-bootstrapped-tasty-tests` = Build.`stdlib-bootstrapped-tasty-tests`
2019
val `tasty-core` = Build.`tasty-core`
2120
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`

project/Build.scala

Lines changed: 23 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -922,91 +922,22 @@ object Build {
922922
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value
923923
)
924924

925-
/** Scala library compiled by dotty using the latest published sources of the 2.13 library
926-
* and the current Scala 3 library sources.
927-
*
928-
* This version of the library is not binary compatible with the Scala 2 compiled library.
929-
* It compiles every file as Scala 3 sources.
930-
*/
931-
lazy val `stdlib-bootstrapped` = project.in(file("stdlib-bootstrapped")).
932-
withCommonSettings(Bootstrapped).
933-
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
934-
settings(commonStdlibBootstrappedSettings).
935-
settings(
936-
Compile/scalacOptions ++= {
937-
Seq(
938-
"-sourcepath",
939-
Seq(
940-
(Compile/sourceManaged).value / "scala-library-src",
941-
(Compile/sourceManaged).value / "dotty-library-src",
942-
).mkString(File.pathSeparator),
943-
)
944-
},
945-
(Compile / sourceGenerators) += Def.task {
946-
val s = streams.value
947-
val cacheDir = s.cacheDirectory
948-
val trgDir = (Compile / sourceManaged).value / "dotty-library-src"
949-
950-
// NOTE `sourceDirectory` is used for actual copying,
951-
// but `sources` are used as cache keys
952-
val dottyLibSourceDirs = (`scala3-library-bootstrapped`/Compile/unmanagedSourceDirectories).value
953-
def dottyLibSources = dottyLibSourceDirs.foldLeft(PathFinder.empty) { (pf, dir) =>
954-
if (!dir.exists) pf else pf +++ (dir ** "*.scala") +++ (dir ** "*.java")
955-
}
956-
957-
val cachedFun = FileFunction.cached(
958-
cacheDir / s"copyDottyLibrarySrc",
959-
FilesInfo.lastModified,
960-
FilesInfo.exists,
961-
) { _ =>
962-
if (trgDir.exists) IO.delete(trgDir)
963-
dottyLibSourceDirs.foreach { dir =>
964-
if (dir.exists) {
965-
s.log.info(s"Copying scala3-library sources from $dir to $trgDir...")
966-
IO.copyDirectory(dir, trgDir)
967-
}
968-
}
969-
970-
((trgDir ** "*.scala") +++ (trgDir ** "*.java")).get.toSet
971-
}
972-
973-
cachedFun(dottyLibSources.get.toSet).toSeq
974-
}.taskValue,
975-
)
976-
977925
/** Scala 2 library compiled by dotty using the latest published sources of the library.
978926
*
979-
* This version of the library is not (yet) binary compatible with the Scala 2 compiled library.
927+
* This version of the library is not (yet) TASTy/binary compatible with the Scala 2 compiled library.
980928
*/
981-
lazy val `stdlib-2_13-bootstrapped` = project.in(file("stdlib-2_13-bootstrapped")).
929+
lazy val `stdlib-bootstrapped` = project.in(file("stdlib-bootstrapped")).
982930
withCommonSettings(Bootstrapped).
983931
dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test").
984-
settings(commonStdlibBootstrappedSettings).
932+
settings(commonBootstrappedSettings).
985933
settings(
986-
scalacOptions += "-Yscala2-stdlib",
934+
moduleName := "scala-library",
935+
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
987936
Compile / scalacOptions ++= {
988937
Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString)
989938
},
990-
// TODO package only TASTy files.
991-
// We first need to check that a project can depend on a JAR that only contains TASTy files.
992-
// Compile / exportJars := true,
993-
// Compile / packageBin / mappings ~= { _.filter(_._2.endsWith(".tasty")) },
994-
mimaCheckDirection := "both",
995-
mimaBackwardIssueFilters := MiMaFilters.StdlibBootstrappedBackwards,
996-
mimaForwardIssueFilters := MiMaFilters.StdlibBootstrappedForward,
997-
mimaPreviousArtifacts += "org.scala-lang" % "scala-library" % stdlibVersion(Bootstrapped),
998-
mimaExcludeAnnotations ++= Seq(
999-
"scala.annotation.experimental",
1000-
"scala.annotation.specialized",
1001-
"scala.annotation.unspecialized",
1002-
),
1003-
)
1004-
1005-
lazy val commonStdlibBootstrappedSettings =
1006-
commonBootstrappedSettings ++ Seq(
1007-
moduleName := "scala-library",
1008-
javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
1009939
Compile / doc / scalacOptions += "-Ydocument-synthetic-types",
940+
scalacOptions += "-Yscala2-stdlib",
1010941
scalacOptions -= "-Xfatal-warnings",
1011942
ivyConfigurations += SourceDeps.hide,
1012943
transitiveClassifiers := Seq("sources"),
@@ -1044,17 +975,30 @@ object Build {
1044975
file.getPath.endsWith("scala-library-src/scala/Nothing.scala") ||
1045976
file.getPath.endsWith("scala-library-src/scala/Null.scala") ||
1046977
file.getPath.endsWith("scala-library-src/scala/Singleton.scala"))),
978+
(Test / managedClasspath) ~= {
979+
_.filterNot(file => file.data.getName == s"scala-library-${stdlibVersion(Bootstrapped)}.jar")
980+
},
1047981
(Compile / sources) := {
1048982
val files = (Compile / sources).value
1049983
val overwritenSourcesDir = (Compile / scalaSource).value
1050984
val overwritenSources = files.flatMap(_.relativeTo(overwritenSourcesDir)).toSet
1051985
val reference = (Compile/sourceManaged).value / "scala-library-src"
1052986
files.filterNot(_.relativeTo(reference).exists(overwritenSources))
1053987
},
1054-
(Test / managedClasspath) ~= {
1055-
_.filterNot(file => file.data.getName == s"scala-library-${stdlibVersion(Bootstrapped)}.jar")
1056-
},
1057-
)
988+
// TODO package only TASTy files.
989+
// We first need to check that a project can depend on a JAR that only contains TASTy files.
990+
// Compile / exportJars := true,
991+
// Compile / packageBin / mappings ~= { _.filter(_._2.endsWith(".tasty")) },
992+
mimaCheckDirection := "both",
993+
mimaBackwardIssueFilters := MiMaFilters.StdlibBootstrappedBackwards,
994+
mimaForwardIssueFilters := MiMaFilters.StdlibBootstrappedForward,
995+
mimaPreviousArtifacts += "org.scala-lang" % "scala-library" % stdlibVersion(Bootstrapped),
996+
mimaExcludeAnnotations ++= Seq(
997+
"scala.annotation.experimental",
998+
"scala.annotation.specialized",
999+
"scala.annotation.unspecialized",
1000+
),
1001+
)
10581002

10591003
/** Test the tasty generated by `stdlib-bootstrapped`
10601004
*

stdlib-2_13-bootstrapped/test/Main.scala

Lines changed: 0 additions & 42 deletions
This file was deleted.

stdlib-bootstrapped/test/Main.scala

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
package hello
22

3+
import scala.util.*
4+
import scala.compiletime.testing.typeChecks
5+
36
enum Color:
47
case Red, Green, Blue
58

69
object HelloWorld:
710
def main(args: Array[String]): Unit = {
8-
println("hello dotty.superbootstrapped!")
11+
println("hello 2.13 library bootstrapped")
912
println(Color.Red)
1013
println(Color.Green)
1114
println(Color.Blue)
15+
16+
testScala2UnapplySignatures()
17+
testScala2ObjectParents()
18+
testScala2ProductMembers()
19+
}
20+
21+
def testScala2UnapplySignatures() = {
22+
val _: Option[Int] = Some.unapply(Some(1))
23+
val _: Option[Int] = Right.unapply(Right(1))
24+
val _: Option[(Int, List[Int])] = ::.unapply(::(1, Nil))
25+
26+
val _: Option[Int] = Tuple1.unapply(Tuple1(1))
27+
val _: Option[(Int, Int)] = Tuple2.unapply((1, 2))
28+
val _: Option[(Int, Int, Int)] = Tuple3.unapply((1, 2, 3))
29+
}
30+
31+
def testScala2ObjectParents() = {
32+
assert(!typeChecks("Either: scala.deriving.Mirror.Sum"))
33+
assert(!typeChecks("Either: scala.deriving.Mirror"))
34+
}
35+
def testScala2ProductMembers() = {
36+
Some(1)._1
37+
Right(1)._1
38+
(1, 2)._1
39+
(1, 2)._2
40+
::(1, Nil)._1
41+
::(1, Nil)._2
1242
}

0 commit comments

Comments
 (0)