diff --git a/build-common/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt b/build-common/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
index fbcd63ea8d1..69b0c08bcf8 100644
--- a/build-common/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
+++ b/build-common/src/org/jetbrains/kotlin/incremental/ProtoCompareGenerated.kt
@@ -855,6 +855,11 @@ open class ProtoCompareGenerated(val oldNameResolver: NameResolver, val newNameR
if (!checkStringEquals(old.message, new.message)) return false
}
+ if (old.hasVersionKind() != new.hasVersionKind()) return false
+ if (old.hasVersionKind()) {
+ if (old.versionKind != new.versionKind) return false
+ }
+
return true
}
@@ -1797,6 +1802,10 @@ fun ProtoBuf.VersionRequirement.hashCode(stringIndexes: (Int) -> Int, fqNameInde
hashCode = 31 * hashCode + stringIndexes(message)
}
+ if (hasVersionKind()) {
+ hashCode = 31 * hashCode + versionKind.hashCode()
+ }
+
return hashCode
}
diff --git a/build-common/test/org/jetbrains/kotlin/serialization/DebugProtoBuf.java b/build-common/test/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
index 8a14015d97a..2fdcc7cf8bb 100644
--- a/build-common/test/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
+++ b/build-common/test/org/jetbrains/kotlin/serialization/DebugProtoBuf.java
@@ -25767,6 +25767,25 @@ public final class DebugProtoBuf {
*
*/
int getMessage();
+
+ /**
+ * optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ *
+ * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + boolean hasVersionKind(); + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind getVersionKind(); } /** * Protobuf type {@code org.jetbrains.kotlin.serialization.VersionRequirement} @@ -25851,6 +25870,17 @@ public final class DebugProtoBuf { message_ = input.readInt32(); break; } + case 48: { + int rawValue = input.readEnum(); + org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind value = org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(6, rawValue); + } else { + bitField0_ |= 0x00000020; + versionKind_ = value; + } + break; + } } } } catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) { @@ -25981,6 +26011,97 @@ public final class DebugProtoBuf { // @@protoc_insertion_point(enum_scope:org.jetbrains.kotlin.serialization.VersionRequirement.Level) } + /** + * Protobuf enum {@code org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind} + */ + public enum VersionKind + implements org.jetbrains.kotlin.protobuf.ProtocolMessageEnum { + /** + *
LANGUAGE_VERSION = 0;
+ */
+ LANGUAGE_VERSION(0, 0),
+ /**
+ * COMPILER_VERSION = 1;
+ */
+ COMPILER_VERSION(1, 1),
+ /**
+ * API_VERSION = 2;
+ */
+ API_VERSION(2, 2),
+ ;
+
+ /**
+ * LANGUAGE_VERSION = 0;
+ */
+ public static final int LANGUAGE_VERSION_VALUE = 0;
+ /**
+ * COMPILER_VERSION = 1;
+ */
+ public static final int COMPILER_VERSION_VALUE = 1;
+ /**
+ * API_VERSION = 2;
+ */
+ public static final int API_VERSION_VALUE = 2;
+
+
+ public final int getNumber() { return value; }
+
+ public static VersionKind valueOf(int value) {
+ switch (value) {
+ case 0: return LANGUAGE_VERSION;
+ case 1: return COMPILER_VERSION;
+ case 2: return API_VERSION;
+ default: return null;
+ }
+ }
+
+ public static org.jetbrains.kotlin.protobuf.Internal.EnumLiteMapoptional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public boolean hasVersionKind() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind getVersionKind() { + return versionKind_; + } + private void initFields() { version_ = 0; versionFull_ = 0; level_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.Level.ERROR; errorCode_ = 0; message_ = 0; + versionKind_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -26138,6 +26285,9 @@ public final class DebugProtoBuf { if (((bitField0_ & 0x00000010) == 0x00000010)) { output.writeInt32(5, message_); } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + output.writeEnum(6, versionKind_.getNumber()); + } getUnknownFields().writeTo(output); } @@ -26167,6 +26317,10 @@ public final class DebugProtoBuf { size += org.jetbrains.kotlin.protobuf.CodedOutputStream .computeInt32Size(5, message_); } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeEnumSize(6, versionKind_.getNumber()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -26294,6 +26448,8 @@ public final class DebugProtoBuf { bitField0_ = (bitField0_ & ~0x00000008); message_ = 0; bitField0_ = (bitField0_ & ~0x00000010); + versionKind_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION; + bitField0_ = (bitField0_ & ~0x00000020); return this; } @@ -26342,6 +26498,10 @@ public final class DebugProtoBuf { to_bitField0_ |= 0x00000010; } result.message_ = message_; + if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + to_bitField0_ |= 0x00000020; + } + result.versionKind_ = versionKind_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -26373,6 +26533,9 @@ public final class DebugProtoBuf { if (other.hasMessage()) { setMessage(other.getMessage()); } + if (other.hasVersionKind()) { + setVersionKind(other.getVersionKind()); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -26655,6 +26818,61 @@ public final class DebugProtoBuf { return this; } + private org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind versionKind_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION; + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public boolean hasVersionKind() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind getVersionKind() { + return versionKind_; + } + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public Builder setVersionKind(org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + versionKind_ = value; + onChanged(); + return this; + } + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public Builder clearVersionKind() { + bitField0_ = (bitField0_ & ~0x00000020); + versionKind_ = org.jetbrains.kotlin.serialization.DebugProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION; + onChanged(); + return this; + } + // @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.VersionRequirement) } @@ -28906,29 +29124,34 @@ public final class DebugProtoBuf { "\003(\0132..org.jetbrains.kotlin.serialization" + ".Annotation\022\033\n\023version_requirement\030\037 \001(\005", "*\005\010d\020\310\001\"&\n\tEnumEntry\022\022\n\004name\030\001 \001(\005B\004\210\265\030\001" + - "*\005\010d\020\310\001\"\347\001\n\022VersionRequirement\022\017\n\007versio" + + "*\005\010d\020\310\001\"\237\003\n\022VersionRequirement\022\017\n\007versio" + "n\030\001 \001(\005\022\024\n\014version_full\030\002 \001(\005\022R\n\005level\030\003" + " \001(\0162<.org.jetbrains.kotlin.serializatio" + "n.VersionRequirement.Level:\005ERROR\022\022\n\nerr" + - "or_code\030\004 \001(\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\"+\n\005" + - "Level\022\013\n\007WARNING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HIDDEN\020" + - "\002\"f\n\027VersionRequirementTable\022K\n\013requirem" + - "ent\030\001 \003(\01326.org.jetbrains.kotlin.seriali" + - "zation.VersionRequirement\"\243\002\n\017PackageFra", - "gment\022@\n\007strings\030\001 \001(\0132/.org.jetbrains.k" + - "otlin.serialization.StringTable\022O\n\017quali" + - "fied_names\030\002 \001(\01326.org.jetbrains.kotlin." + - "serialization.QualifiedNameTable\022<\n\007pack" + - "age\030\003 \001(\0132+.org.jetbrains.kotlin.seriali" + - "zation.Package\0228\n\005class\030\004 \003(\0132).org.jetb" + - "rains.kotlin.serialization.Class*\005\010d\020\310\001*" + - "9\n\010Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABST" + - "RACT\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n\010INTE" + - "RNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022\n\n\006PU", - "BLIC\020\003\022\023\n\017PRIVATE_TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q" + - "\n\nMemberKind\022\017\n\013DECLARATION\020\000\022\021\n\rFAKE_OV" + - "ERRIDE\020\001\022\016\n\nDELEGATION\020\002\022\017\n\013SYNTHESIZED\020" + - "\003B\017B\rDebugProtoBuf" + "or_code\030\004 \001(\005\022\025\n\007message\030\005 \001(\005B\004\230\265\030\001\022j\n\014" + + "version_kind\030\006 \001(\0162B.org.jetbrains.kotli" + + "n.serialization.VersionRequirement.Versi" + + "onKind:\020LANGUAGE_VERSION\"+\n\005Level\022\013\n\007WAR" + + "NING\020\000\022\t\n\005ERROR\020\001\022\n\n\006HIDDEN\020\002\"J\n\013Version", + "Kind\022\024\n\020LANGUAGE_VERSION\020\000\022\024\n\020COMPILER_V" + + "ERSION\020\001\022\017\n\013API_VERSION\020\002\"f\n\027VersionRequ" + + "irementTable\022K\n\013requirement\030\001 \003(\01326.org." + + "jetbrains.kotlin.serialization.VersionRe" + + "quirement\"\243\002\n\017PackageFragment\022@\n\007strings" + + "\030\001 \001(\0132/.org.jetbrains.kotlin.serializat" + + "ion.StringTable\022O\n\017qualified_names\030\002 \001(\013" + + "26.org.jetbrains.kotlin.serialization.Qu" + + "alifiedNameTable\022<\n\007package\030\003 \001(\0132+.org." + + "jetbrains.kotlin.serialization.Package\0228", + "\n\005class\030\004 \003(\0132).org.jetbrains.kotlin.ser" + + "ialization.Class*\005\010d\020\310\001*9\n\010Modality\022\t\n\005F" + + "INAL\020\000\022\010\n\004OPEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006SEALED" + + "\020\003*b\n\nVisibility\022\014\n\010INTERNAL\020\000\022\013\n\007PRIVAT" + + "E\020\001\022\r\n\tPROTECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017PRIVAT" + + "E_TO_THIS\020\004\022\t\n\005LOCAL\020\005*Q\n\nMemberKind\022\017\n\013" + + "DECLARATION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016\n\nDELE" + + "GATION\020\002\022\017\n\013SYNTHESIZED\020\003B\017B\rDebugProtoB" + + "uf" }; org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -29056,7 +29279,7 @@ public final class DebugProtoBuf { internal_static_org_jetbrains_kotlin_serialization_VersionRequirement_fieldAccessorTable = new org.jetbrains.kotlin.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_org_jetbrains_kotlin_serialization_VersionRequirement_descriptor, - new java.lang.String[] { "Version", "VersionFull", "Level", "ErrorCode", "Message", }); + new java.lang.String[] { "Version", "VersionFull", "Level", "ErrorCode", "Message", "VersionKind", }); internal_static_org_jetbrains_kotlin_serialization_VersionRequirementTable_descriptor = getDescriptor().getMessageTypes().get(15); internal_static_org_jetbrains_kotlin_serialization_VersionRequirementTable_fieldAccessorTable = new diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt index bd3370a28a9..3523208b11d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.resolve.annotations.argumentValue import org.jetbrains.kotlin.resolve.calls.checkers.isOperatorMod import org.jetbrains.kotlin.resolve.calls.checkers.shouldWarnAboutDeprecatedModFromBuiltIns import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe +import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor import org.jetbrains.kotlin.serialization.deserialization.descriptors.VersionRequirement @@ -292,8 +293,17 @@ class DeprecationResolver( if (versionRequirement != null) { // We're using ApiVersion because it's convenient to compare versions, "-api-version" is not involved in any way // TODO: usage of ApiVersion is confusing here, refactor - if (ApiVersion.createByVersionRequirement(versionRequirement) > - ApiVersion.createByLanguageVersion(languageVersionSettings.languageVersion)) { + val requiredVersion = ApiVersion.createByVersionRequirement(versionRequirement) + val currentVersion = when (versionRequirement.kind) { + ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION -> + ApiVersion.createByLanguageVersion(languageVersionSettings.languageVersion) + ProtoBuf.VersionRequirement.VersionKind.API_VERSION -> + languageVersionSettings.apiVersion + ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION -> + ApiVersion.LATEST_STABLE + else -> null + } + if (currentVersion != null && currentVersion < requiredVersion) { result.add(DeprecatedByVersionRequirement(versionRequirement, target)) } } diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt index f1e24767171..7f46c3f1f34 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt @@ -633,6 +633,15 @@ class DescriptorSerializer private constructor( DeprecationLevel.HIDDEN.toString() -> proto.level = ProtoBuf.VersionRequirement.Level.HIDDEN } + val versionKind = (args[RequireKotlinNames.VERSION_KIND] as? EnumValue)?.value?.name?.asString() + when (versionKind) { + ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION.toString() -> { /* LANGUAGE_VERSION is the default kind */ } + ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION.toString() -> + proto.versionKind = ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION + ProtoBuf.VersionRequirement.VersionKind.API_VERSION.toString() -> + proto.versionKind = ProtoBuf.VersionRequirement.VersionKind.API_VERSION + } + val errorCode = (args[RequireKotlinNames.ERROR_CODE] as? IntValue)?.value if (errorCode != null && errorCode != -1) { proto.errorCode = errorCode @@ -656,6 +665,7 @@ class DescriptorSerializer private constructor( val VERSION = Name.identifier("version") val MESSAGE = Name.identifier("message") val LEVEL = Name.identifier("level") + val VERSION_KIND = Name.identifier("versionKind") val ERROR_CODE = Name.identifier("errorCode") val VERSION_REGEX: Regex = "(0|[1-9][0-9]*)".let { number -> Regex("$number\\.$number(\\.$number)?") } diff --git a/compiler/testData/versionRequirement/apiVersionViaAnnotation.kt b/compiler/testData/versionRequirement/apiVersionViaAnnotation.kt new file mode 100644 index 00000000000..0917e02e9b3 --- /dev/null +++ b/compiler/testData/versionRequirement/apiVersionViaAnnotation.kt @@ -0,0 +1,19 @@ +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +package test + +import kotlin.internal.RequireKotlin +import kotlin.internal.RequireKotlinVersionKind + +@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, RequireKotlinVersionKind.API_VERSION, 42) +class Klass + +class Konstructor @RequireKotlin("1.1", "message", DeprecationLevel.WARNING, RequireKotlinVersionKind.API_VERSION, 42) constructor() + +@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, RequireKotlinVersionKind.API_VERSION, 42) +typealias Typealias = String + +@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, RequireKotlinVersionKind.API_VERSION, 42) +fun function() {} + +@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, RequireKotlinVersionKind.API_VERSION, 42) +val property = "" diff --git a/compiler/testData/versionRequirement/languageVersionViaAnnotation.kt b/compiler/testData/versionRequirement/languageVersionViaAnnotation.kt index b2e0f477ffc..10f302bcb12 100644 --- a/compiler/testData/versionRequirement/languageVersionViaAnnotation.kt +++ b/compiler/testData/versionRequirement/languageVersionViaAnnotation.kt @@ -3,16 +3,16 @@ package test import kotlin.internal.RequireKotlin -@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, 42) +@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, errorCode = 42) class Klass -class Konstructor @RequireKotlin("1.1", "message", DeprecationLevel.WARNING, 42) constructor() +class Konstructor @RequireKotlin("1.1", "message", DeprecationLevel.WARNING, errorCode = 42) constructor() -@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, 42) +@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, errorCode = 42) typealias Typealias = String -@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, 42) +@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, errorCode = 42) fun function() {} -@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, 42) +@RequireKotlin("1.1", "message", DeprecationLevel.WARNING, errorCode = 42) val property = "" diff --git a/compiler/tests/org/jetbrains/kotlin/serialization/VersionRequirementTest.kt b/compiler/tests/org/jetbrains/kotlin/serialization/VersionRequirementTest.kt index fab1d35e26a..e96eacce33f 100644 --- a/compiler/tests/org/jetbrains/kotlin/serialization/VersionRequirementTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/serialization/VersionRequirementTest.kt @@ -40,6 +40,7 @@ class VersionRequirementTest : TestCaseWithTmpdir() { expectedVersionRequirement: VersionRequirement.Version, expectedLevel: DeprecationLevel, expectedMessage: String?, + expectedVersionKind: ProtoBuf.VersionRequirement.VersionKind, expectedErrorCode: Int?, vararg fqNames: String ) { @@ -66,6 +67,7 @@ class VersionRequirementTest : TestCaseWithTmpdir() { assertEquals(expectedVersionRequirement, requirement.version) assertEquals(expectedLevel, requirement.level) assertEquals(expectedMessage, requirement.message) + assertEquals(expectedVersionKind, requirement.kind) assertEquals(expectedErrorCode, requirement.errorCode) } @@ -96,7 +98,7 @@ class VersionRequirementTest : TestCaseWithTmpdir() { } fun testSuspendFun() { - doTest(VersionRequirement.Version(1, 1), DeprecationLevel.ERROR, null, null, + doTest(VersionRequirement.Version(1, 1), DeprecationLevel.ERROR, null, ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION, null, "test.topLevel", "test.Foo.member", "test.Foo.
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + boolean hasVersionKind(); + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind getVersionKind(); } /** * Protobuf type {@code org.jetbrains.kotlin.serialization.VersionRequirement} @@ -19996,6 +20015,18 @@ public final class ProtoBuf { message_ = input.readInt32(); break; } + case 48: { + int rawValue = input.readEnum(); + org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind value = org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind.valueOf(rawValue); + if (value == null) { + unknownFieldsCodedOutput.writeRawVarint32(tag); + unknownFieldsCodedOutput.writeRawVarint32(rawValue); + } else { + bitField0_ |= 0x00000020; + versionKind_ = value; + } + break; + } } } } catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) { @@ -20094,6 +20125,71 @@ public final class ProtoBuf { // @@protoc_insertion_point(enum_scope:org.jetbrains.kotlin.serialization.VersionRequirement.Level) } + /** + * Protobuf enum {@code org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind} + */ + public enum VersionKind + implements org.jetbrains.kotlin.protobuf.Internal.EnumLite { + /** + *
LANGUAGE_VERSION = 0;
+ */
+ LANGUAGE_VERSION(0, 0),
+ /**
+ * COMPILER_VERSION = 1;
+ */
+ COMPILER_VERSION(1, 1),
+ /**
+ * API_VERSION = 2;
+ */
+ API_VERSION(2, 2),
+ ;
+
+ /**
+ * LANGUAGE_VERSION = 0;
+ */
+ public static final int LANGUAGE_VERSION_VALUE = 0;
+ /**
+ * COMPILER_VERSION = 1;
+ */
+ public static final int COMPILER_VERSION_VALUE = 1;
+ /**
+ * API_VERSION = 2;
+ */
+ public static final int API_VERSION_VALUE = 2;
+
+
+ public final int getNumber() { return value; }
+
+ public static VersionKind valueOf(int value) {
+ switch (value) {
+ case 0: return LANGUAGE_VERSION;
+ case 1: return COMPILER_VERSION;
+ case 2: return API_VERSION;
+ default: return null;
+ }
+ }
+
+ public static org.jetbrains.kotlin.protobuf.Internal.EnumLiteMapoptional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public boolean hasVersionKind() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind getVersionKind() { + return versionKind_; + } + private void initFields() { version_ = 0; versionFull_ = 0; level_ = org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.Level.ERROR; errorCode_ = 0; message_ = 0; + versionKind_ = org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -20251,6 +20373,9 @@ public final class ProtoBuf { if (((bitField0_ & 0x00000010) == 0x00000010)) { output.writeInt32(5, message_); } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + output.writeEnum(6, versionKind_.getNumber()); + } output.writeRawBytes(unknownFields); } @@ -20280,6 +20405,10 @@ public final class ProtoBuf { size += org.jetbrains.kotlin.protobuf.CodedOutputStream .computeInt32Size(5, message_); } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeEnumSize(6, versionKind_.getNumber()); + } size += unknownFields.size(); memoizedSerializedSize = size; return size; @@ -20384,6 +20513,8 @@ public final class ProtoBuf { bitField0_ = (bitField0_ & ~0x00000008); message_ = 0; bitField0_ = (bitField0_ & ~0x00000010); + versionKind_ = org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION; + bitField0_ = (bitField0_ & ~0x00000020); return this; } @@ -20427,6 +20558,10 @@ public final class ProtoBuf { to_bitField0_ |= 0x00000010; } result.message_ = message_; + if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + to_bitField0_ |= 0x00000020; + } + result.versionKind_ = versionKind_; result.bitField0_ = to_bitField0_; return result; } @@ -20448,6 +20583,9 @@ public final class ProtoBuf { if (other.hasMessage()) { setMessage(other.getMessage()); } + if (other.hasVersionKind()) { + setVersionKind(other.getVersionKind()); + } setUnknownFields( getUnknownFields().concat(other.unknownFields)); return this; @@ -20731,6 +20869,61 @@ public final class ProtoBuf { return this; } + private org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind versionKind_ = org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION; + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public boolean hasVersionKind() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind getVersionKind() { + return versionKind_; + } + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public Builder setVersionKind(org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + versionKind_ = value; + + return this; + } + /** + *
optional .org.jetbrains.kotlin.serialization.VersionRequirement.VersionKind version_kind = 6 [default = LANGUAGE_VERSION];
+ *
+ * + * Which version is this requirement for. For example, if version_kind = API_VERSION, this declaration requires the API version + * (the "-api-version" argument value when compiling the call site) to be of at least the specified value + *+ */ + public Builder clearVersionKind() { + bitField0_ = (bitField0_ & ~0x00000020); + versionKind_ = org.jetbrains.kotlin.serialization.ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION; + + return this; + } + // @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.serialization.VersionRequirement) } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/VersionRequirement.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/VersionRequirement.kt index fd9c42ee2f1..13b0e29eef7 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/VersionRequirement.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/VersionRequirement.kt @@ -33,6 +33,7 @@ class VersionRequirementTable private constructor(private val infos: List