Revert metadata version reading advancement for JS/Common

This commit reverts 59e2101a25 partially,
leaving only the implementation of KT-25972 for JVM. The reason is that
we can't fully commit to stabilizing JS (and .kotlin_metadata) binary
metadata formats so much as to postpone any changes done to it for a
whole release year time. It's likely that we will need to update JS
metadata format incompatibly pretty soon, and with the scheme where we
can read the "current + 1" version, it'd require advancing the metadata
version by 2, which would break the nice property that the metadata
version (since Kotlin 1.4) is equal to the version of the compiler that
produced it.

See KT-25972
This commit is contained in:
Alexander Udalov
2018-08-24 19:10:17 +02:00
parent 4067d6b196
commit afd53c9870
5 changed files with 11 additions and 12 deletions
@@ -14,8 +14,8 @@ import java.io.InputStream
* of the core protobuf messages (metadata.proto).
*/
class BuiltInsBinaryVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
override fun isCompatible() =
isMetadataVersionCompatible()
override fun isCompatible(): Boolean =
this.isCompatibleTo(INSTANCE)
companion object {
@JvmField
@@ -35,12 +35,6 @@ abstract class BinaryVersion(private vararg val numbers: Int) {
else major == ourVersion.major && minor <= ourVersion.minor
}
// In Kotlin 1.4, all metadata versions (JVM, JS, built-ins/metadata) are going to be advanced to 1.4.0.
// Kotlin 1.3 is able to read metadata of versions up to Kotlin 1.4
protected fun isMetadataVersionCompatible(): Boolean {
return major == 1 && minor <= 4
}
fun isAtLeast(major: Int, minor: Int, patch: Int): Boolean {
if (this.major > major) return true
if (this.major < major) return false