Skip to content

Commit 882a9c9

Browse files
committed
[DO NOT MERGE] Hack to allow running the tests with the new stdlib
1 parent 783ea88 commit 882a9c9

File tree

10 files changed

+44
-17
lines changed

10 files changed

+44
-17
lines changed

compiler/test/dotty/Properties.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@ object Properties {
8484
/** scala-library TASTy jar */
8585
def scalaLibraryTasty: Option[String] = sys.props.get("dotty.tests.tasties.scalaLibrary")
8686

87+
def fullScalaLibrary: Option[String] = sys.props.get("dotty.tests.fullstdlib.scalaLibrary")
88+
8789
/** If we are using the scala-library TASTy jar */
88-
def usingScalaLibraryTasty: Boolean = scalaLibraryTasty.isDefined
90+
def usingScalaLibraryTasty: Boolean = scalaLibraryTasty.isDefined || usingFullScalaLibrary
8991
/** If we are using the scala-library TASTy jar */
9092

91-
def usingScalaLibraryCCTasty: Boolean = scalaLibraryTasty.exists(_.contains("scala2-library-cc-tasty"))
93+
def usingScalaLibraryCCTasty: Boolean = scalaLibraryTasty.exists(_.contains("scala2-library-cc-tasty")) || usingFullScalaLibrary
94+
95+
def usingFullScalaLibrary: Boolean = fullScalaLibrary.isDefined
9296

9397
/** scala-asm jar */
9498
def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm")

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,15 @@ class CompilationTests {
214214
)
215215
}.checkExpectedErrors()
216216

217-
@Test def explicitNullsPos: Unit = {
217+
@Test def explicitNullsPos: Unit =
218218
implicit val testGroup: TestGroup = TestGroup("explicitNullsPos")
219-
aggregateTests(
220-
compileFilesInDir("tests/explicit-nulls/pos", explicitNullsOptions),
221-
compileFilesInDir("tests/explicit-nulls/flexible-types-common", explicitNullsOptions),
222-
compileFilesInDir("tests/explicit-nulls/unsafe-common", explicitNullsOptions and "-language:unsafeNulls" and "-Yno-flexible-types"),
223-
)
224-
}.checkCompile()
219+
if !Properties.usingFullScalaLibrary then
220+
aggregateTests(
221+
compileFilesInDir("tests/explicit-nulls/pos", explicitNullsOptions),
222+
compileFilesInDir("tests/explicit-nulls/flexible-types-common", explicitNullsOptions),
223+
compileFilesInDir("tests/explicit-nulls/unsafe-common", explicitNullsOptions and "-language:unsafeNulls" and "-Yno-flexible-types"),
224+
).checkCompile()
225+
end explicitNullsPos
225226

226227
@Test def explicitNullsWarn: Unit = {
227228
implicit val testGroup: TestGroup = TestGroup("explicitNullsWarn")

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ object TestConfiguration {
2525
"-Xverify-signatures"
2626
)
2727

28-
val basicClasspath = mkClasspath(
29-
Properties.scalaLibraryTasty.toList ::: List(
30-
Properties.scalaLibrary,
31-
Properties.dottyLibrary
32-
))
28+
val basicClasspath =
29+
if Properties.usingFullScalaLibrary then
30+
println(s"using the full stdlib")
31+
mkClasspath(Properties.fullScalaLibrary.toList)
32+
else
33+
mkClasspath(
34+
Properties.scalaLibraryTasty.toList ::: List(
35+
Properties.scalaLibrary,
36+
Properties.dottyLibrary
37+
))
3338

3439
val withCompilerClasspath = mkClasspath(
3540
Properties.scalaLibraryTasty.toList ::: List(

library/src/scala/collection/immutable/List.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import language.experimental.captureChecking
1919

2020
import scala.annotation.unchecked.uncheckedVariance
2121
import scala.annotation.tailrec
22+
import scala.annotation.publicInBinary
2223
import mutable.{Builder, ListBuffer}
2324
import scala.collection.generic.{CommonErrors, DefaultSerializable}
2425
import scala.runtime.Statics.releaseFence
@@ -661,7 +662,12 @@ final case class :: [+A](override val head: A, private[scala] var next: List[A @
661662
override def headOption: Some[A] = Some(head)
662663
override def tail: List[A] = next
663664

664-
def next$access$1 = next
665+
// This method is generated by the Scala 2 Compiler automatically
666+
// but Scala 3. To keep binary compatiblity, we define it manually
667+
// and make it public in the binary. To maintain source compatibity
668+
// We make the method private.
669+
@publicInBinary
670+
private[::] def next$access$1 = next
665671

666672
}
667673

project/Build.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ object Build {
208208
//
209209
object Scala2LibraryCCTasty extends Scala2Library
210210

211+
object ScalaFullLibrary extends Scala2Library
212+
211213
// Set in SBT with:
212214
// - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryJar` (default)
213215
// - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryTasty`
@@ -786,10 +788,16 @@ object Build {
786788
log.warn("Scala 2 library TASTy is ignored on non-bootstrapped compiler")
787789
Seq.empty
788790
}
791+
792+
def fullLibraryPathProperty: Seq[String] = Seq(
793+
s"-Ddotty.tests.fullstdlib.scalaLibrary=${jars("scala-library-unified")}",
794+
)
795+
789796
val scala2LibraryTasty = scala2Library.value match {
790-
case Scala2LibraryJar => Seq.empty
791-
case Scala2LibraryTasty => libraryPathProperty("scala2-library-tasty")
797+
case Scala2LibraryJar => Seq.empty
798+
case Scala2LibraryTasty => libraryPathProperty("scala2-library-tasty")
792799
case Scala2LibraryCCTasty => libraryPathProperty("scala2-library-cc-tasty")
800+
case ScalaFullLibrary => fullLibraryPathProperty
793801
}
794802

795803
scala2LibraryTasty ++ Seq(
@@ -917,6 +925,8 @@ object Build {
917925
case Some(jar) => extraClasspath :+= jar
918926
case None => log.warn("Scala2LibraryCCTasty is ignored on non-bootstrapped compiler")
919927
}
928+
case ScalaFullLibrary =>
929+
log.error(s"scala full library not supported")
920930
}
921931

922932
if (decompile && !args.contains("-classpath"))
@@ -1039,6 +1049,7 @@ object Build {
10391049
"tasty-core" -> (LocalProject("tasty-core-bootstrapped") / Compile / packageBin).value.getAbsolutePath,
10401050
"scala2-library-tasty" -> (LocalProject("scala2-library-tasty") / Compile / packageBin).value.getAbsolutePath,
10411051
"scala2-library-cc-tasty" -> (LocalProject("scala2-library-cc-tasty") / Compile / packageBin).value.getAbsolutePath,
1052+
"scala-library-unified" -> (LocalProject("scala-library-bootstrapped") / Compile / packageBin).value.getAbsolutePath,
10421053
)
10431054
},
10441055

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)