Skip to content

Commit 13582bf

Browse files
authored
Merge pull request #12426 from dotty-staging/tasty/first-release-version
First stable Tasty release
2 parents 7baac02 + 18258e4 commit 13582bf

File tree

3 files changed

+52
-22
lines changed

3 files changed

+52
-22
lines changed

project/Build.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,12 @@ object Build {
258258
// Settings used when compiling dotty (both non-bootstrapped and bootstrapped)
259259
lazy val commonDottySettings = commonSettings ++ Seq(
260260
// Manually set the standard library to use
261-
autoScalaLibrary := false
261+
autoScalaLibrary := false,
262+
classpathOptions ~= (old =>
263+
old
264+
.withAutoBoot(false) // no library on the compiler bootclasspath - we may need a more recent version
265+
.withFilterLibrary(false) // ...instead, we put it on the compiler classpath
266+
),
262267
)
263268

264269
lazy val commonScala2Settings = commonSettings ++ Seq(

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ object TastyFormat {
284284
* compatibility, but remains backwards compatible, with all
285285
* preceeding `MinorVersion`.
286286
*/
287-
final val MinorVersion: Int = 0
287+
final val MinorVersion: Int = 1
288288

289289
/**Natural Number. The `ExperimentalVersion` allows for
290290
* experimentation with changes to TASTy without committing
@@ -300,14 +300,31 @@ object TastyFormat {
300300
* is able to read final TASTy documents if the file's
301301
* `MinorVersion` is strictly less than the current value.
302302
*/
303-
final val ExperimentalVersion: Int = 3
303+
final val ExperimentalVersion: Int = 1
304304

305305
/**This method implements a binary relation (`<:<`) between two TASTy versions.
306+
*
306307
* We label the lhs `file` and rhs `compiler`.
307308
* if `file <:< compiler` then the TASTy file is valid to be read.
308309
*
309-
* TASTy versions have a partial order,
310-
* for example `a <:< b` and `b <:< a` are both false if `a` and `b` have different major versions.
310+
* A TASTy version, e.g. `v := 28.0-3` is composed of three fields:
311+
* - v.major == 28
312+
* - v.minor == 0
313+
* - v.experimental == 3
314+
*
315+
* TASTy versions have a partial order, for example,
316+
* `a <:< b` and `b <:< a` are both false if
317+
* - `a` and `b` have different `major` fields.
318+
* - `a` and `b` have the same `major` & `minor` fields,
319+
* but different `experimental` fields, both non-zero.
320+
*
321+
* A TASTy version with a zero value for its `experimental` field
322+
* is considered to be stable. Files with a stable TASTy version
323+
* can be read by a compiler with an unstable TASTy version,
324+
* (where the compiler's TASTy version has a higher `minor` field).
325+
*
326+
* A compiler with a stable TASTy version can never read a file
327+
* with an unstable TASTy version.
311328
*
312329
* We follow the given algorithm:
313330
* ```

tasty/test/dotty/tools/tasty/TastyVersionFormatTest.scala

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,69 @@ class TastyVersionFormatTest {
1111
import TastyVersionFormatTest._
1212

1313
/** aliases `TastyVersion.apply` */
14-
def compiler(major: Int, minor: Int, experimental: Int) = TastyVersion(major, minor, experimental)
14+
def compiler(major: Int, minor: Int, experimental: Experimental) = TastyVersion(major, minor, experimental)
1515

1616
/** aliases `TastyVersion.apply` */
17-
def file(major: Int, minor: Int, experimental: Int) = TastyVersion(major, minor, experimental)
17+
def file(major: Int, minor: Int, experimental: Experimental) = TastyVersion(major, minor, experimental)
1818

1919
@Test def accept_ExperimentalReadEQExperimental_EQMinor: Unit = {
20-
assert(file(28,1,1) <:< compiler(28,1,1)) // same minor, same experimental
20+
assert(file(28,1,Exp(1)) <:< compiler(28,1,Exp(1))) // same minor, same experimental
2121
}
2222

2323
@Test def accept_ExperimentalReadFinal_LTMinor: Unit = {
24-
assert(file(28,0,0) <:< compiler(28,1,1)) // preceding minor
24+
assert(file(28,0,Final) <:< compiler(28,1,Exp(1))) // preceding minor
2525
}
2626

2727
@Test def accept_FinalReadFinal_LTEqualMinor: Unit = {
28-
assert(file(28,0,0) <:< compiler(28,1,0)) // preceding minor
29-
assert(file(28,0,0) <:< compiler(28,0,0)) // same minor
28+
assert(file(28,0,Final) <:< compiler(28,1,Final)) // preceding minor
29+
assert(file(28,0,Final) <:< compiler(28,0,Final)) // same minor
3030
}
3131

3232
/** these cases are unrelated because a final compiler can only read final tasty of <= minor version */
3333
@Test def reject_FinalReadFinal_GTMinor: Unit = {
34-
assert(file(28,2,0) unrelatedTo compiler(28,1,0)) // succeeding minor
34+
assert(file(28,2,Final) unrelatedTo compiler(28,1,Final)) // succeeding minor
3535
}
3636

3737
/** these cases are unrelated because a final compiler can not read experimental tasty */
3838
@Test def reject_FinalReadExperimental: Unit = {
39-
assert(file(28,0,1) unrelatedTo compiler(28,1,0)) // preceding minor
40-
assert(file(28,1,1) unrelatedTo compiler(28,1,0)) // same minor
41-
assert(file(28,2,1) unrelatedTo compiler(28,1,0)) // succeeding minor
39+
assert(file(28,0,Exp(1)) unrelatedTo compiler(28,1,Final)) // preceding minor
40+
assert(file(28,1,Exp(1)) unrelatedTo compiler(28,1,Final)) // same minor
41+
assert(file(28,2,Exp(1)) unrelatedTo compiler(28,1,Final)) // succeeding minor
4242
}
4343

4444
/** These cases are unrelated because an experimental compiler can only read final tasty of < minor version */
4545
@Test def reject_ExperimentalReadFinal_GTEqualMinor: Unit = {
46-
assert(file(28,2,0) unrelatedTo compiler(28,1,1)) // succeeding minor
47-
assert(file(28,1,0) unrelatedTo compiler(28,1,1)) // equal minor
46+
assert(file(28,2,Final) unrelatedTo compiler(28,1,Exp(1))) // succeeding minor
47+
assert(file(28,1,Final) unrelatedTo compiler(28,1,Exp(1))) // equal minor
4848
}
4949

5050
/**These cases are unrelated because both compiler and file are experimental,
5151
* and with unequal experimental part.
5252
*/
5353
@Test def reject_ExperimentalReadNEExperimental: Unit = {
54-
assert(file(28,1,2) unrelatedTo compiler(28,1,1)) // same minor version, succeeding experimental
55-
assert(file(28,1,1) unrelatedTo compiler(28,1,2)) // same minor version, preceding experimental
54+
assert(file(28,1,Exp(2)) unrelatedTo compiler(28,1,Exp(1))) // same minor version, succeeding experimental
55+
assert(file(28,1,Exp(1)) unrelatedTo compiler(28,1,Exp(2))) // same minor version, preceding experimental
5656
}
5757

5858
/** these cases are unrelated because the major version must be identical */
5959
@Test def reject_NEMajor: Unit = {
60-
assert(file(27,0,0) unrelatedTo compiler(28,0,0)) // less than
61-
assert(file(29,0,0) unrelatedTo compiler(28,0,0)) // greater than
60+
assert(file(27,0,Final) unrelatedTo compiler(28,0,Final)) // less than
61+
assert(file(29,0,Final) unrelatedTo compiler(28,0,Final)) // greater than
6262
}
6363

6464
}
6565

6666
object TastyVersionFormatTest {
6767

68-
case class TastyVersion(major: Int, minor: Int, experimental: Int) { file =>
68+
type Experimental = Int
69+
val Final: Experimental = 0
70+
def Exp(i: Int): Experimental = i.ensuring(_ > 0)
71+
72+
case class TastyVersion(major: Int, minor: Int, experimental: Experimental) { file =>
73+
assert(major >= 0)
74+
assert(minor >= 0)
75+
assert(experimental >= 0)
76+
6977
def <:<(compiler: TastyVersion): Boolean = TastyFormat.isVersionCompatible(
7078
fileMajor = file.major,
7179
fileMinor = file.minor,

0 commit comments

Comments
 (0)