BinaryVersion: introduce isCompatibleWithCurrentCompilerVersion
This commit is contained in:
+1
-1
@@ -155,7 +155,7 @@ class MetadataPackageFragment(
|
||||
private fun readProto(stream: InputStream): Triple<ProtoBuf.PackageFragment, NameResolverImpl, BuiltInsBinaryVersion> {
|
||||
val version = BuiltInsBinaryVersion.readFrom(stream)
|
||||
|
||||
if (!version.isCompatible()) {
|
||||
if (!version.isCompatibleWithCurrentCompilerVersion()) {
|
||||
// TODO: report a proper diagnostic
|
||||
throw UnsupportedOperationException(
|
||||
"Kotlin metadata definition format version is not supported: " +
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
class JvmMetadataVersion(versionArray: IntArray, val isStrictSemantics: Boolean) : BinaryVersion(*versionArray) {
|
||||
constructor(vararg numbers: Int) : this(numbers, isStrictSemantics = false)
|
||||
|
||||
override fun isCompatible(): Boolean =
|
||||
override fun isCompatibleWithCurrentCompilerVersion(): Boolean =
|
||||
// NOTE: 1.0 is a pre-Kotlin-1.0 metadata version, with which the current compiler is incompatible
|
||||
(major != 1 || minor != 0) &&
|
||||
if (isStrictSemantics) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.io.InputStream
|
||||
* of the core protobuf messages (metadata.proto).
|
||||
*/
|
||||
class BuiltInsBinaryVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
|
||||
override fun isCompatible(): Boolean =
|
||||
override fun isCompatibleWithCurrentCompilerVersion(): Boolean =
|
||||
this.isCompatibleTo(INSTANCE)
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -13,7 +13,7 @@ fun InputStream.readBuiltinsPackageFragment(): Pair<ProtoBuf.PackageFragment?, B
|
||||
use { stream ->
|
||||
val version = BuiltInsBinaryVersion.readFrom(stream)
|
||||
val proto =
|
||||
if (version.isCompatible()) ProtoBuf.PackageFragment.parseFrom(
|
||||
if (version.isCompatibleWithCurrentCompilerVersion()) ProtoBuf.PackageFragment.parseFrom(
|
||||
stream,
|
||||
ExtensionRegistryLite.newInstance().apply(BuiltInsProtoBuf::registerAllExtensions)
|
||||
)
|
||||
|
||||
@@ -25,7 +25,10 @@ abstract class BinaryVersion(private vararg val numbers: Int) {
|
||||
numbers.asList().subList(3, numbers.size).toList()
|
||||
} else emptyList()
|
||||
|
||||
abstract fun isCompatible(): Boolean
|
||||
@Deprecated("Please use isCompatibleWithCurrentCompilerVersion()", ReplaceWith("isCompatibleWithCurrentCompilerVersion()"))
|
||||
fun isCompatible(): Boolean = isCompatibleWithCurrentCompilerVersion()
|
||||
|
||||
abstract fun isCompatibleWithCurrentCompilerVersion(): Boolean
|
||||
|
||||
fun toArray(): IntArray = numbers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user