Use JvmName on kotlin.Metadata parameters to improve public API

#KT-26359 Fixed
This commit is contained in:
Alexander Udalov
2018-08-30 18:10:00 +02:00
parent 8365836753
commit f63cf9d506
9 changed files with 50 additions and 53 deletions
@@ -50,7 +50,7 @@ object JvmProtoBufUtil {
JvmNameResolver(JvmProtoBuf.StringTableTypes.parseDelimitedFrom(this, EXTENSION_REGISTRY), strings)
/**
* Serializes [message] and [stringTable] into a string array which must be further written to [Metadata.d1]
* Serializes [message] and [stringTable] into a string array which must be further written to [Metadata.data1]
*/
@JvmStatic
fun writeData(message: MessageLite, stringTable: JvmStringTable): Array<String> =
@@ -14,8 +14,6 @@
* limitations under the License.
*/
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
package kotlin.reflect.jvm
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
@@ -35,10 +33,12 @@ import kotlin.reflect.jvm.internal.deserializeToDescriptor
*/
fun <R> Function<R>.reflect(): KFunction<R>? {
val annotation = javaClass.getAnnotation(Metadata::class.java) ?: return null
val data = annotation.d1.takeUnless(Array<String>::isEmpty) ?: return null
val (nameResolver, proto) = JvmProtoBufUtil.readFunctionDataFrom(data, annotation.d2)
val metadataVersion =
JvmMetadataVersion(annotation.mv, (annotation.xi and JvmAnnotationNames.METADATA_STRICT_VERSION_SEMANTICS_FLAG) != 0)
val data = annotation.data1.takeUnless(Array<String>::isEmpty) ?: return null
val (nameResolver, proto) = JvmProtoBufUtil.readFunctionDataFrom(data, annotation.data2)
val metadataVersion = JvmMetadataVersion(
annotation.metadataVersion,
(annotation.extraInt and JvmAnnotationNames.METADATA_STRICT_VERSION_SEMANTICS_FLAG) != 0
)
val descriptor = deserializeToDescriptor(
javaClass, proto, nameResolver, TypeTable(proto.typeTable), metadataVersion, MemberDeserializer::loadFunction