Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible

This commit is contained in:
Mikhail Glukhikh
2022-12-02 16:38:59 +01:00
parent 52ab565cc6
commit 0c4a0360ac
67 changed files with 399 additions and 163 deletions
@@ -14,7 +14,7 @@ package org.jetbrains.kotlin.metadata.deserialization
* - Patch version can be increased freely and is only supposed to be used for debugging. Increase the patch version when you
* make a change to binaries which is both forward- and backward compatible.
*/
abstract class BinaryVersion(private vararg val numbers: Int) {
abstract class BinaryVersion(private vararg val numbers: Int) : Comparable<BinaryVersion> {
val major: Int = numbers.getOrNull(0) ?: UNKNOWN
val minor: Int = numbers.getOrNull(1) ?: UNKNOWN
val patch: Int = numbers.getOrNull(2) ?: UNKNOWN
@@ -87,6 +87,18 @@ abstract class BinaryVersion(private vararg val numbers: Int) {
return result
}
override fun compareTo(other: BinaryVersion): Int {
return when {
major > other.major -> 1
major < other.major -> -1
minor > other.minor -> 1
minor < other.minor -> -1
patch > other.patch -> 1
patch < other.patch -> -1
else -> 0
}
}
companion object {
const val MAX_LENGTH = 1024
private const val UNKNOWN = -1