Refactor JvmMemberSignature:
- Deprecate asString() in favor of toString() - Rename desc to descriptor with deprecation
This commit is contained in:
committed by
Space Team
parent
0fcb4c3fb0
commit
f327d68fe0
@@ -1092,15 +1092,15 @@ public final class kotlinx/metadata/jvm/JvmExtensionsKt {
|
||||
|
||||
public final class kotlinx/metadata/jvm/JvmFieldSignature : kotlinx/metadata/jvm/JvmMemberSignature {
|
||||
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
|
||||
public fun asString ()Ljava/lang/String;
|
||||
public final fun component1 ()Ljava/lang/String;
|
||||
public final fun component2 ()Ljava/lang/String;
|
||||
public final fun copy (Ljava/lang/String;Ljava/lang/String;)Lkotlinx/metadata/jvm/JvmFieldSignature;
|
||||
public static synthetic fun copy$default (Lkotlinx/metadata/jvm/JvmFieldSignature;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lkotlinx/metadata/jvm/JvmFieldSignature;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public fun getDesc ()Ljava/lang/String;
|
||||
public fun getDescriptor ()Ljava/lang/String;
|
||||
public fun getName ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class kotlinx/metadata/jvm/JvmFlag {
|
||||
@@ -1134,10 +1134,11 @@ public final class kotlinx/metadata/jvm/JvmFunctionExtensionVisitor$Companion {
|
||||
}
|
||||
|
||||
public abstract class kotlinx/metadata/jvm/JvmMemberSignature {
|
||||
public abstract fun asString ()Ljava/lang/String;
|
||||
public abstract fun getDesc ()Ljava/lang/String;
|
||||
public final fun asString ()Ljava/lang/String;
|
||||
public final fun getDesc ()Ljava/lang/String;
|
||||
public abstract fun getDescriptor ()Ljava/lang/String;
|
||||
public abstract fun getName ()Ljava/lang/String;
|
||||
public final fun toString ()Ljava/lang/String;
|
||||
public abstract fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class kotlinx/metadata/jvm/JvmMetadataUtil {
|
||||
@@ -1149,15 +1150,15 @@ public final class kotlinx/metadata/jvm/JvmMetadataUtil {
|
||||
|
||||
public final class kotlinx/metadata/jvm/JvmMethodSignature : kotlinx/metadata/jvm/JvmMemberSignature {
|
||||
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
|
||||
public fun asString ()Ljava/lang/String;
|
||||
public final fun component1 ()Ljava/lang/String;
|
||||
public final fun component2 ()Ljava/lang/String;
|
||||
public final fun copy (Ljava/lang/String;Ljava/lang/String;)Lkotlinx/metadata/jvm/JvmMethodSignature;
|
||||
public static synthetic fun copy$default (Lkotlinx/metadata/jvm/JvmMethodSignature;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lkotlinx/metadata/jvm/JvmMethodSignature;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public fun getDesc ()Ljava/lang/String;
|
||||
public fun getDescriptor ()Ljava/lang/String;
|
||||
public fun getName ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public class kotlinx/metadata/jvm/JvmPackageExtensionVisitor : kotlinx/metadata/jvm/JvmDeclarationContainerExtensionVisitor, kotlinx/metadata/KmPackageExtensionVisitor {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -11,23 +11,27 @@ import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMemberSignature as J
|
||||
* A signature of a JVM method or field.
|
||||
*
|
||||
* @property name name of method or field
|
||||
* @property desc JVM descriptor of a method, e.g. `(Ljava/lang/Object;)Z`, or a field type, e.g. `Ljava/lang/String;`
|
||||
* @property descriptor JVM descriptor of a method, e.g. `(Ljava/lang/Object;)Z`, or a field type, e.g. `Ljava/lang/String;`
|
||||
*/
|
||||
sealed class JvmMemberSignature {
|
||||
|
||||
abstract val name: String
|
||||
abstract val desc: String
|
||||
abstract val descriptor: String
|
||||
|
||||
@Deprecated("Use descriptor instead", ReplaceWith("descriptor"), level = DeprecationLevel.WARNING)
|
||||
val desc: String get() = descriptor
|
||||
|
||||
@Deprecated("asString() is deprecated as redundant. Use toString() instead", ReplaceWith("toString()"), level = DeprecationLevel.WARNING)
|
||||
fun asString(): String = toString()
|
||||
|
||||
/**
|
||||
* Returns a string representation of the signature.
|
||||
*
|
||||
* In case of a method it's just [name] and [desc] concatenated together, e.g. `equals(Ljava/lang/Object;)Z`
|
||||
* In case of a method it's just [name] and [descriptor] concatenated together, e.g. `equals(Ljava/lang/Object;)Z`
|
||||
*
|
||||
* In case of a field [name] and [desc] are concatenated with `:` separator, e.g. `value:Ljava/lang/String;`
|
||||
* In case of a field [name] and [descriptor] are concatenated with `:` separator, e.g. `value:Ljava/lang/String;`
|
||||
*/
|
||||
abstract fun asString(): String
|
||||
|
||||
final override fun toString() = asString()
|
||||
abstract override fun toString(): String
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,8 +41,8 @@ sealed class JvmMemberSignature {
|
||||
*
|
||||
* @see JvmMemberSignature
|
||||
*/
|
||||
data class JvmMethodSignature(override val name: String, override val desc: String) : JvmMemberSignature() {
|
||||
override fun asString() = name + desc
|
||||
data class JvmMethodSignature(override val name: String, override val descriptor: String) : JvmMemberSignature() {
|
||||
override fun toString() = name + descriptor
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,8 +52,8 @@ data class JvmMethodSignature(override val name: String, override val desc: Stri
|
||||
*
|
||||
* @see JvmMemberSignature
|
||||
*/
|
||||
data class JvmFieldSignature(override val name: String, override val desc: String) : JvmMemberSignature() {
|
||||
override fun asString() = "$name:$desc"
|
||||
data class JvmFieldSignature(override val name: String, override val descriptor: String) : JvmMemberSignature() {
|
||||
override fun toString() = "$name:$descriptor"
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -209,7 +209,7 @@ internal class JvmMetadataExtensions : MetadataExtensions {
|
||||
if (fieldSignature != null) {
|
||||
signature.field = JvmProtoBuf.JvmFieldSignature.newBuilder().also { field ->
|
||||
field.name = c[fieldSignature.name]
|
||||
field.desc = c[fieldSignature.desc]
|
||||
field.desc = c[fieldSignature.descriptor]
|
||||
}.build()
|
||||
}
|
||||
if (getterSignature != null) {
|
||||
@@ -323,6 +323,6 @@ internal class JvmMetadataExtensions : MetadataExtensions {
|
||||
private fun JvmMemberSignature.toJvmMethodSignature(c: WriteContext): JvmProtoBuf.JvmMethodSignature =
|
||||
JvmProtoBuf.JvmMethodSignature.newBuilder().apply {
|
||||
name = c[this@toJvmMethodSignature.name]
|
||||
desc = c[this@toJvmMethodSignature.desc]
|
||||
desc = c[this@toJvmMethodSignature.descriptor]
|
||||
}.build()
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class MetadataSmokeTest {
|
||||
|
||||
val inlineFunctions = classMetadata.toKmClass().functions
|
||||
.filter { Flag.Function.IS_INLINE(it.flags) }
|
||||
.mapNotNull { it.signature?.asString() }
|
||||
.mapNotNull { it.signature?.toString() }
|
||||
|
||||
assertEquals(
|
||||
listOf("foo(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;"),
|
||||
|
||||
Reference in New Issue
Block a user