Write version requirements for @JvmField in interface companion
This commit is contained in:
@@ -58,8 +58,12 @@ class JavaClassesSerializerExtension : KotlinSerializerExtensionBase(BuiltInSeri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serializeProperty(descriptor: PropertyDescriptor, proto: ProtoBuf.Property.Builder) {
|
override fun serializeProperty(
|
||||||
super.serializeProperty(descriptor, proto)
|
descriptor: PropertyDescriptor,
|
||||||
|
proto: ProtoBuf.Property.Builder,
|
||||||
|
versionRequirementTable: MutableVersionRequirementTable
|
||||||
|
) {
|
||||||
|
super.serializeProperty(descriptor, proto, versionRequirementTable)
|
||||||
if (descriptor.visibility == JavaVisibilities.PACKAGE_VISIBILITY) {
|
if (descriptor.visibility == JavaVisibilities.PACKAGE_VISIBILITY) {
|
||||||
proto.setExtension(JavaClassProtoBuf.isPackagePrivateField, true)
|
proto.setExtension(JavaClassProtoBuf.isPackagePrivateField, true)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -155,7 +155,11 @@ class JvmSerializerExtension(private val bindings: JvmSerializationBindings, sta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serializeProperty(descriptor: PropertyDescriptor, proto: ProtoBuf.Property.Builder) {
|
override fun serializeProperty(
|
||||||
|
descriptor: PropertyDescriptor,
|
||||||
|
proto: ProtoBuf.Property.Builder,
|
||||||
|
versionRequirementTable: MutableVersionRequirementTable
|
||||||
|
) {
|
||||||
val signatureSerializer = SignatureSerializer()
|
val signatureSerializer = SignatureSerializer()
|
||||||
|
|
||||||
val getter = descriptor.getter
|
val getter = descriptor.getter
|
||||||
@@ -181,6 +185,11 @@ class JvmSerializerExtension(private val bindings: JvmSerializationBindings, sta
|
|||||||
proto.setExtension(JvmProtoBuf.isMovedFromInterfaceCompanion, 1)
|
proto.setExtension(JvmProtoBuf.isMovedFromInterfaceCompanion, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (JvmAbi.isInterfaceCompanionWithBackingFieldsInOuter(descriptor.containingDeclaration)) {
|
||||||
|
assert(!proto.hasVersionRequirement()) { "VersionRequirement should be empty for $descriptor" }
|
||||||
|
proto.versionRequirement =
|
||||||
|
writeVersionRequirement(1, 2, 70, ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION, versionRequirementTable)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serializeErrorType(type: KotlinType, builder: ProtoBuf.Type.Builder) {
|
override fun serializeErrorType(type: KotlinType, builder: ProtoBuf.Type.Builder) {
|
||||||
|
|||||||
+1
-2
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
|
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
|
||||||
import org.jetbrains.kotlin.resolve.MemberComparator
|
import org.jetbrains.kotlin.resolve.MemberComparator
|
||||||
import org.jetbrains.kotlin.resolve.RequireKotlinNames
|
import org.jetbrains.kotlin.resolve.RequireKotlinNames
|
||||||
import org.jetbrains.kotlin.resolve.annotations.hasJvmDefaultAnnotation
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.components.isActualParameterWithAnyExpectedDefault
|
import org.jetbrains.kotlin.resolve.calls.components.isActualParameterWithAnyExpectedDefault
|
||||||
import org.jetbrains.kotlin.resolve.checkers.KotlinVersionStringAnnotationValueChecker
|
import org.jetbrains.kotlin.resolve.checkers.KotlinVersionStringAnnotationValueChecker
|
||||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||||
@@ -241,7 +240,7 @@ class DescriptorSerializer private constructor(
|
|||||||
builder.versionRequirement = writeVersionRequirementDependingOnCoroutinesVersion()
|
builder.versionRequirement = writeVersionRequirementDependingOnCoroutinesVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
extension.serializeProperty(descriptor, builder)
|
extension.serializeProperty(descriptor, builder, versionRequirementTable)
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -44,7 +44,11 @@ abstract class SerializerExtension {
|
|||||||
open fun serializeFunction(descriptor: FunctionDescriptor, proto: ProtoBuf.Function.Builder) {
|
open fun serializeFunction(descriptor: FunctionDescriptor, proto: ProtoBuf.Function.Builder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun serializeProperty(descriptor: PropertyDescriptor, proto: ProtoBuf.Property.Builder) {
|
open fun serializeProperty(
|
||||||
|
descriptor: PropertyDescriptor,
|
||||||
|
proto: ProtoBuf.Property.Builder,
|
||||||
|
versionRequirementTable: MutableVersionRequirementTable
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun serializeEnumEntry(descriptor: ClassDescriptor, proto: ProtoBuf.EnumEntry.Builder) {
|
open fun serializeEnumEntry(descriptor: ClassDescriptor, proto: ProtoBuf.EnumEntry.Builder) {
|
||||||
|
|||||||
+5
-1
@@ -53,7 +53,11 @@ open class KotlinSerializerExtensionBase(private val protocol: SerializerExtensi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serializeProperty(descriptor: PropertyDescriptor, proto: ProtoBuf.Property.Builder) {
|
override fun serializeProperty(
|
||||||
|
descriptor: PropertyDescriptor,
|
||||||
|
proto: ProtoBuf.Property.Builder,
|
||||||
|
versionRequirementTable: MutableVersionRequirementTable
|
||||||
|
) {
|
||||||
for (annotation in descriptor.nonSourceAnnotations) {
|
for (annotation in descriptor.nonSourceAnnotations) {
|
||||||
proto.addExtension(protocol.propertyAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
proto.addExtension(protocol.propertyAnnotation, annotationSerializer.serializeAnnotation(annotation))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
interface Base {
|
||||||
|
companion object {
|
||||||
|
@Suppress("INAPPLICABLE_JVM_FIELD")
|
||||||
|
@JvmField
|
||||||
|
val foo = object : Base {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -188,4 +188,11 @@ class VersionRequirementTest : TestCaseWithTmpdir() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testJvmFieldInInterfaceCompanion() {
|
||||||
|
doTest(
|
||||||
|
VersionRequirement.Version(1, 2, 70), DeprecationLevel.ERROR, null, COMPILER_VERSION, null,
|
||||||
|
fqNames = listOf("test.Base.Companion.foo")
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -54,12 +54,16 @@ class KotlinJavascriptSerializerExtension(
|
|||||||
super.serializeClass(descriptor, proto, versionRequirementTable)
|
super.serializeClass(descriptor, proto, versionRequirementTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serializeProperty(descriptor: PropertyDescriptor, proto: ProtoBuf.Property.Builder) {
|
override fun serializeProperty(
|
||||||
|
descriptor: PropertyDescriptor,
|
||||||
|
proto: ProtoBuf.Property.Builder,
|
||||||
|
versionRequirementTable: MutableVersionRequirementTable
|
||||||
|
) {
|
||||||
val id = getFileId(descriptor)
|
val id = getFileId(descriptor)
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
proto.setExtension(JsProtoBuf.propertyContainingFileId, id)
|
proto.setExtension(JsProtoBuf.propertyContainingFileId, id)
|
||||||
}
|
}
|
||||||
super.serializeProperty(descriptor, proto)
|
super.serializeProperty(descriptor, proto, versionRequirementTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serializeFunction(descriptor: FunctionDescriptor, proto: ProtoBuf.Function.Builder) {
|
override fun serializeFunction(descriptor: FunctionDescriptor, proto: ProtoBuf.Function.Builder) {
|
||||||
|
|||||||
Reference in New Issue
Block a user