Skip to content

Commit 6c52cbc

Browse files
committed
scala-release: Adjust MiMa filters; Revert changes to tasty module
1 parent ea97378 commit 6c52cbc

File tree

8 files changed

+42
-27
lines changed

8 files changed

+42
-27
lines changed

compiler/src/dotty/tools/dotc/config/ScalaRelease.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package dotty.tools.dotc.config
22

3-
import dotty.tools.tasty.TastyVersion
4-
53
enum ScalaRelease(val majorVersion: Int, val minorVersion: Int) extends Ordered[ScalaRelease]:
64
case Release3_0 extends ScalaRelease(3, 0)
75
case Release3_1 extends ScalaRelease(3, 1)

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ import xsbti.AnalysisCallback
3838
import plugins._
3939
import java.util.concurrent.atomic.AtomicInteger
4040
import java.nio.file.InvalidPathException
41-
import dotty.tools.tasty.{ TastyFormat, TastyVersion }
41+
import dotty.tools.tasty.TastyFormat
4242
import dotty.tools.dotc.config.{ NoScalaVersion, SpecificScalaVersion, AnyScalaVersion, ScalaBuild }
43+
import dotty.tools.dotc.core.tasty.TastyVersion
4344

4445
object Contexts {
4546

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotc
33
package core
44
package classfile
55

6-
import dotty.tools.tasty.{ TastyFormat, TastyReader, TastyHeaderUnpickler, TastyVersion }
6+
import dotty.tools.tasty.{ TastyFormat, TastyReader, TastyHeaderUnpickler }
77

88
import Contexts._, Symbols._, Types._, Names._, StdNames._, NameOps._, Scopes._, Decorators._
99
import SymDenotations._, unpickleScala2.Scala2Unpickler._, Constants._, Annotations._, util.Spans._
@@ -20,6 +20,7 @@ import java.util.UUID
2020
import scala.collection.immutable
2121
import scala.collection.mutable.{ ListBuffer, ArrayBuffer }
2222
import scala.annotation.switch
23+
import tasty.TastyVersion
2324
import typer.Checking.checkNonCyclic
2425
import io.{AbstractFile, PlainFile, ZipArchive}
2526
import scala.util.control.NonFatal
@@ -964,12 +965,12 @@ class ClassfileParser(
964965
|found: ${fileTastyVersion.show}
965966
""".stripMargin)
966967

967-
val isTastyReadable = TastyFormat.isVersionCompatible(fileVersion = fileTastyVersion, compilerVersion = TastyVersion.compilerVersion)
968+
val isTastyReadable = fileTastyVersion.isCompatibleWith(TastyVersion.compilerVersion)
968969
if !isTastyReadable then
969970
reportWrongTasty("its TASTy format cannot be read by the compiler", TastyVersion.compilerVersion)
970971
else
971972
val isTastyCompatible =
972-
TastyFormat.isVersionCompatible(fileVersion = fileTastyVersion, compilerVersion = ctx.tastyVersion) ||
973+
fileTastyVersion.isCompatibleWith(ctx.tastyVersion) ||
973974
classRoot.symbol.showFullName.startsWith("scala.") // References to stdlib are considered safe because we check the values of @since annotations
974975
if !isTastyCompatible then
975976
reportWrongTasty(s"its TASTy format is not compatible with the one of the targeted Scala release (${ctx.scalaRelease.show})", ctx.tastyVersion)

compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import classfile.ClassfileParser
1010
import Names.SimpleName
1111
import TreeUnpickler.UnpickleMode
1212

13-
import dotty.tools.tasty.{ TastyReader, TastyVersion }
13+
import dotty.tools.tasty.TastyReader
1414
import dotty.tools.tasty.TastyFormat.{ASTsSection, PositionsSection, CommentsSection}
1515

1616
object DottyUnpickler {

tasty/src/dotty/tools/tasty/TastyVersion.scala renamed to compiler/src/dotty/tools/dotc/core/tasty/TastyVersion.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
package dotty.tools.tasty
1+
package dotty.tools.dotc.core.tasty
2+
3+
import dotty.tools.tasty.TastyFormat
24

35
case class TastyVersion(major: Int, minor: Int, experimental: Int) {
4-
def show = "" + major + "." + minor + "-" + experimental
6+
def show = s"$major.$minor-$experimental"
7+
8+
def isCompatibleWith(that: TastyVersion): Boolean = TastyFormat.isVersionCompatible(
9+
this.major, this.minor, this.experimental,
10+
that.major, that.minor, that.experimental
11+
)
512
}
613

714
object TastyVersion {
@@ -13,4 +20,4 @@ object TastyVersion {
1320
TastyVersion(tastyMajor, tastyMinor, 0)
1421
}
1522

16-
}
23+
}

project/MiMaFilters.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ object MiMaFilters {
2525
ProblemFilters.exclude[MissingFieldProblem]("scala.runtime.stdLibPatches.language.3.1"),
2626
ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$3$u002E1$"),
2727
ProblemFilters.exclude[MissingClassProblem]("scala.runtime.stdLibPatches.language$3$u002E1$minusmigration$"),
28+
29+
// Private to the compiler - needed for forward binary compatibility
30+
ProblemFilters.exclude[MissingClassProblem]("scala.annotation.since")
2831
)
2932
}

tasty/src/dotty/tools/tasty/TastyFormat.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,16 @@ object TastyFormat {
338338
* @syntax markdown
339339
*/
340340
def isVersionCompatible(
341-
fileVersion: TastyVersion,
342-
compilerVersion: TastyVersion
341+
fileMajor: Int,
342+
fileMinor: Int,
343+
fileExperimental: Int,
344+
compilerMajor: Int,
345+
compilerMinor: Int,
346+
compilerExperimental: Int
343347
): Boolean = (
344-
fileVersion.major == compilerVersion.major &&
345-
( fileVersion.minor == compilerVersion.minor && fileVersion.experimental == compilerVersion.experimental // full equality
346-
|| fileVersion.minor < compilerVersion.minor && fileVersion.experimental == 0 // stable backwards compatibility
348+
fileMajor == compilerMajor &&
349+
( fileMinor == compilerMinor && fileExperimental == compilerExperimental // full equality
350+
|| fileMinor < compilerMinor && fileExperimental == 0 // stable backwards compatibility
347351
)
348352
)
349353

tasty/src/dotty/tools/tasty/TastyHeaderUnpickler.scala

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class TastyHeaderUnpickler(reader: TastyReader) {
4545
val fileMajor = readNat()
4646
if (fileMajor <= 27) { // old behavior before `tasty-core` 3.0.0-M4
4747
val fileMinor = readNat()
48-
val fileTastyVersion = TastyVersion(fileMajor, fileMinor, 0)
49-
val signature = signatureString(fileTastyVersion, TastyVersion.compilerVersion)
48+
val signature = signatureString(fileMajor, fileMinor, 0)
5049
throw new UnpickleException(signature + backIncompatAddendum + toolingAddendum)
5150
}
5251
else {
@@ -60,15 +59,17 @@ class TastyHeaderUnpickler(reader: TastyReader) {
6059
new String(bytes, start.index, length)
6160
}
6261

63-
val fileTastyVersion = TastyVersion(fileMajor, fileMinor, fileExperimental)
64-
6562
val validVersion = TastyFormat.isVersionCompatible(
66-
fileVersion = fileTastyVersion,
67-
compilerVersion = TastyVersion.compilerVersion
63+
fileMajor = fileMajor,
64+
fileMinor = fileMinor,
65+
fileExperimental = fileExperimental,
66+
compilerMajor = MajorVersion,
67+
compilerMinor = MinorVersion,
68+
compilerExperimental = ExperimentalVersion
6869
)
6970

7071
check(validVersion, {
71-
val signature = signatureString(fileTastyVersion, TastyVersion.compilerVersion)
72+
val signature = signatureString(fileMajor, fileMinor, fileExperimental)
7273
val producedByAddendum = s"\nThe TASTy file was produced by $toolingVersion.$toolingAddendum"
7374
val msg = (
7475
if (fileExperimental != 0) unstableAddendum
@@ -99,16 +100,16 @@ object TastyHeaderUnpickler {
99100
""
100101
)
101102

102-
private def signatureString(found: TastyVersion, expected: TastyVersion) = {
103+
private def signatureString(fileMajor: Int, fileMinor: Int, fileExperimental: Int) = {
103104
def showMinorVersion(min: Int, exp: Int) = {
104105
val expStr = if (exp == 0) "" else s" [unstable release: $exp]"
105106
s"$min$expStr"
106107
}
107-
val expectedMinorVersion = showMinorVersion(expected.minor, expected.experimental)
108-
val foundMinorVersion = showMinorVersion(found.minor, found.experimental)
108+
val minorVersion = showMinorVersion(MinorVersion, ExperimentalVersion)
109+
val fileMinorVersion = showMinorVersion(fileMinor, fileExperimental)
109110
s"""TASTy signature has wrong version.
110-
| expected: {majorVersion: ${expected.major}, minorVersion: $expectedMinorVersion}
111-
| found : {majorVersion: ${found.major}, minorVersion: $foundMinorVersion}
111+
| expected: {majorVersion: $MajorVersion, minorVersion: $minorVersion}
112+
| found : {majorVersion: $fileMajor, minorVersion: $fileMinorVersion}
112113
|
113114
|""".stripMargin
114115
}

0 commit comments

Comments
 (0)