Skip to content

Commit a986531

Browse files
[build] Refine checkReleasedTastyVersion logic to handle using unstable reference version of a new minor (#22789)
In #22786 we've followed the process and updated referenceVersion to latest released version which happens to be 3.7.0-RC1 producing TASTY `28.7-experimental-1`. All nightly version when patch > 0 should be using TASTy version incremented by 1, in case of unexpected binary breakage. However non-bootstrapped tests (eg. FromTastyTest) would fail if we'd increase tasty version to `28.8-experimental-1` because these require the produced and consumed Scala files (eg. in `FromTastyTest`) to either: - be produced by older stable compiler - produced with exactly the same TASTy version Because of that we're adding special case to checking version of released tasty to allow using the same tasty format as unstable reference version if the reference version is the RC release of new minor (patch == 0) Fixes #22788 [skip ci]
2 parents fd35e0b + 4603daf commit a986531

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Diff for: project/Build.scala

+18-6
Original file line numberDiff line numberDiff line change
@@ -2534,11 +2534,14 @@ object Build {
25342534

25352535
/* Tests TASTy version invariants during NIGHLY, RC or Stable releases */
25362536
def checkReleasedTastyVersion(): Unit = {
2537-
lazy val (scalaMinor, scalaPatch, scalaIsRC) = baseVersion.split("\\.|-").take(4) match {
2538-
case Array("3", minor, patch) => (minor.toInt, patch.toInt, false)
2539-
case Array("3", minor, patch, _) => (minor.toInt, patch.toInt, true)
2537+
case class ScalaVersion(minor: Int, patch: Int, isRC: Boolean)
2538+
def parseScalaVersion(version: String): ScalaVersion = version.split("\\.|-").take(4) match {
2539+
case Array("3", minor, patch) => ScalaVersion(minor.toInt, patch.toInt, false)
2540+
case Array("3", minor, patch, _) => ScalaVersion(minor.toInt, patch.toInt, true)
25402541
case other => sys.error(s"Invalid Scala base version string: $baseVersion")
25412542
}
2543+
lazy val version = parseScalaVersion(baseVersion)
2544+
lazy val referenceV = parseScalaVersion(referenceVersion)
25422545
lazy val (tastyMinor, tastyIsExperimental) = expectedTastyVersion.split("\\.|-").take(4) match {
25432546
case Array("28", minor) => (minor.toInt, false)
25442547
case Array("28", minor, "experimental", _) => (minor.toInt, true)
@@ -2547,13 +2550,22 @@ object Build {
25472550

25482551
if(isNightly) {
25492552
assert(tastyIsExperimental, "TASTY needs to be experimental in nightly builds")
2550-
val expectedTastyMinor = if(scalaPatch == 0) scalaMinor else scalaMinor + 1
2553+
val expectedTastyMinor = version.patch match {
2554+
case 0 => version.minor
2555+
case 1 if referenceV.patch == 0 && referenceV.isRC =>
2556+
// Special case for a period when reference version is a new unstable minor
2557+
// Needed for non_bootstrapped tests requiring either stable tasty or the same experimental version produced by both reference and bootstrapped compiler
2558+
assert(version.minor == referenceV.minor, "Expected reference and base version to use the same minor")
2559+
version.minor
2560+
case _ => version.minor + 1
2561+
}
25512562
assert(tastyMinor == expectedTastyMinor, "Invalid TASTy minor version")
25522563
}
25532564

25542565
if(isRelease) {
2555-
assert(scalaMinor == tastyMinor, "Minor versions of TASTY vesion and Scala version should match in release builds")
2556-
if (scalaIsRC && scalaPatch == 0)
2566+
assert(version.minor == tastyMinor, "Minor versions of TASTY vesion and Scala version should match in release builds")
2567+
assert(!referenceV.isRC, "Stable release needs to use stable compiler version")
2568+
if (version.isRC && version.patch == 0)
25572569
assert(tastyIsExperimental, "TASTy should be experimental when releasing a new minor version RC")
25582570
else
25592571
assert(!tastyIsExperimental, "Stable version cannot use experimental TASTY")

0 commit comments

Comments
 (0)