Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify & clarify TASTy isVersionCompatible #13280

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 8 additions & 34 deletions tasty/src/dotty/tools/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -327,29 +327,12 @@ object TastyFormat {
* with an unstable TASTy version.
*
* We follow the given algorithm:
*
* ```
* if file.major != compiler.major then
* return incompatible
* if compiler.experimental == 0 then
* if file.experimental != 0 then
* return incompatible
* if file.minor > compiler.minor then
* return incompatible
* else
* return compatible
* else invariant[compiler.experimental != 0]
* if file.experimental == compiler.experimental then
* if file.minor == compiler.minor then
* return compatible (all fields equal)
* else
* return incompatible
* else if file.experimental == 0,
* if file.minor < compiler.minor then
* return compatible (an experimental version can read a previous released version)
* else
* return incompatible (an experimental version cannot read its own minor version or any later version)
* else invariant[file.experimental is non-0 and different than compiler.experimental]
* return incompatible
* (fileMajor, fileMinor, fileExperimental) match
* case (`compilerMajor`, `compilerMinor`, `compilerExperimental`) => true // full equality
* case (`compilerMajor`, minor, 0) if minor < compilerMinor => true // stable backwards compatibility
* case _ => false
* ```
* @syntax markdown
*/
Expand All @@ -361,18 +344,9 @@ object TastyFormat {
compilerMinor: Int,
compilerExperimental: Int
): Boolean = (
fileMajor == compilerMajor && (
if (fileExperimental == compilerExperimental) {
if (compilerExperimental == 0) {
fileMinor <= compilerMinor
}
else {
fileMinor == compilerMinor
}
}
else {
fileExperimental == 0 && fileMinor < compilerMinor
}
fileMajor == compilerMajor &&
( fileMinor == compilerMinor && fileExperimental == compilerExperimental // full equality
|| fileMinor < compilerMinor && fileExperimental == 0 // stable backwards compatibility
)
)

Expand Down