@@ -93,18 +93,21 @@ object Build {
9393
9494 /** Version of the Scala compiler used to build the artifacts.
9595 * Reference version should track the latest version pushed to Maven:
96- * - In main branch it should be the last RC version (using experimental TASTy required for non-bootstrapped tests)
96+ * - In main branch it should be the last RC version
9797 * - In release branch it should be the last stable release
98- * 3.6.0-RC1 was released as 3.6.0 - it's having and experimental TASTy version
98+ *
99+ * Warning: Change of this variable needs to be consulted with `expectedTastyVersion`
99100 */
100- val referenceVersion = " 3.6.0 "
101+ val referenceVersion = " 3.6.3-RC1 "
101102
102103 /** Version of the Scala compiler targeted in the current release cycle
103104 * Contains a version without RC/SNAPSHOT/NIGHTLY specific suffixes
104105 * Should be updated ONLY after release or cutoff for previous release cycle.
105106 *
106107 * Should only be referred from `dottyVersion` or settings/tasks requiring simplified version string,
107108 * eg. `compatMode` or Windows native distribution version.
109+ *
110+ * Warning: Change of this variable might require updating `expectedTastyVersion`
108111 */
109112 val developedVersion = " 3.6.4"
110113
@@ -116,6 +119,25 @@ object Build {
116119 * During final, stable release is set exactly to `developedVersion`.
117120 */
118121 val baseVersion = s " $developedVersion-RC1 "
122+
123+ /** The version of TASTY that should be emitted, checked in runtime test
124+ * For defails on how TASTY version should be set see related discussions:
125+ * - https://github.com/scala/scala3/issues/13447#issuecomment-912447107
126+ * - https://github.com/scala/scala3/issues/14306#issuecomment-1069333516
127+ * - https://github.com/scala/scala3/pull/19321
128+ *
129+ * Simplified rules, given 3.$minor.$patch = $developedVersion
130+ * - Major version is always 28
131+ * - TASTY minor version:
132+ * - in main (NIGHTLY): {if $patch == 0 then $minor else ${minor + 1}}
133+ * - in release branch is always equal to $minor
134+ * - TASTY experimental version:
135+ * - in main (NIGHTLY) is always experimental
136+ * - in release candidate branch is experimental if {patch == 0}
137+ * - in stable release is always non-experimetnal
138+ */
139+ val expectedTastyVersion = " 28.7-experimental-1"
140+ checkReleasedTastyVersion()
119141
120142 /** Final version of Scala compiler, controlled by environment variables. */
121143 val dottyVersion = {
@@ -149,9 +171,9 @@ object Build {
149171 * For a developedVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
150172 * - `3.M.0` if `P > 0`
151173 * - `3.(M-1).0` if `P = 0`
152- * 3.6.1 is an exception from this rule - 3.6.0 was a broken release
174+ * 3.6.2 is an exception from this rule - 3.6.0 was a broken release, 3.6.1 was hotfix (unstable) release
153175 */
154- val mimaPreviousDottyVersion = " 3.6.1 "
176+ val mimaPreviousDottyVersion = " 3.6.2 "
155177
156178 /** LTS version against which we check binary compatibility.
157179 *
@@ -2424,6 +2446,9 @@ object Build {
24242446 settings(disableDocSetting).
24252447 settings(
24262448 versionScheme := Some (" semver-spec" ),
2449+ Test / envVars ++= Map (
2450+ " EXPECTED_TASTY_VERSION" -> expectedTastyVersion,
2451+ ),
24272452 if (mode == Bootstrapped ) Def .settings(
24282453 commonMiMaSettings,
24292454 mimaForwardIssueFilters := MiMaFilters .TastyCore .ForwardsBreakingChanges ,
@@ -2473,6 +2498,34 @@ object Build {
24732498 case Bootstrapped => commonBootstrappedSettings
24742499 })
24752500 }
2501+
2502+ /* Tests TASTy version invariants during NIGHLY, RC or Stable releases */
2503+ def checkReleasedTastyVersion (): Unit = {
2504+ lazy val (scalaMinor, scalaPatch, scalaIsRC) = baseVersion.split(" \\ .|-" ).take(4 ) match {
2505+ case Array (" 3" , minor, patch) => (minor.toInt, patch.toInt, false )
2506+ case Array (" 3" , minor, patch, _) => (minor.toInt, patch.toInt, true )
2507+ case other => sys.error(s " Invalid Scala base version string: $baseVersion" )
2508+ }
2509+ lazy val (tastyMinor, tastyIsExperimental) = expectedTastyVersion.split(" \\ .|-" ).take(4 ) match {
2510+ case Array (" 28" , minor) => (minor.toInt, false )
2511+ case Array (" 28" , minor, " experimental" , _) => (minor.toInt, true )
2512+ case other => sys.error(s " Invalid TASTy version string: $expectedTastyVersion" )
2513+ }
2514+
2515+ if (isNightly) {
2516+ assert(tastyIsExperimental, " TASTY needs to be experimental in nightly builds" )
2517+ val expectedTastyMinor = if (scalaPatch == 0 ) scalaMinor else scalaMinor + 1
2518+ assert(tastyMinor == expectedTastyMinor, " Invalid TASTy minor version" )
2519+ }
2520+
2521+ if (isRelease) {
2522+ assert(scalaMinor == tastyMinor, " Minor versions of TASTY vesion and Scala version should match in release builds" )
2523+ if (scalaIsRC && scalaPatch == 0 )
2524+ assert(tastyIsExperimental, " TASTy should be experimental when releasing a new minor version RC" )
2525+ else
2526+ assert(! tastyIsExperimental, " Stable version cannot use experimental TASTY" )
2527+ }
2528+ }
24762529}
24772530
24782531object ScaladocConfigs {
0 commit comments