Support reading binary metadata of the next major release

Already existing tests testRequireKotlinInNestedClassesAgainst14{,Js}
now check that there's no error when loading a module/class with
metadata version 1.4.0

 #KT-25972 Fixed
This commit is contained in:
Alexander Udalov
2018-08-17 19:25:01 +02:00
parent 852760b3b0
commit 59e2101a25
5 changed files with 14 additions and 9 deletions
@@ -14,7 +14,8 @@ import java.io.InputStream
* of the core protobuf messages (metadata.proto).
*/
class BuiltInsBinaryVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
override fun isCompatible() = this.isCompatibleTo(INSTANCE)
override fun isCompatible() =
isMetadataVersionCompatible()
companion object {
@JvmField
@@ -35,6 +35,12 @@ 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