BinaryVersion: introduce isCompatibleWithCurrentCompilerVersion

This commit is contained in:
Mikhail Glukhikh
2022-12-02 14:08:27 +01:00
parent f6b8b3438a
commit 89dd28226b
12 changed files with 16 additions and 13 deletions
@@ -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