Drop synthetic class kind Function, drop Metadata#xi

This commit is contained in:
Alexander Udalov
2016-01-18 05:58:20 +03:00
parent aef6d49b48
commit 9620893fa4
6 changed files with 1 additions and 25 deletions
@@ -231,7 +231,6 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
@Override
public Unit invoke(AnnotationVisitor av) {
writeAnnotationData(av, serializer, functionProto, false);
av.visit(JvmAnnotationNames.SYNTHETIC_CLASS_KIND_FIELD_NAME, KotlinClassHeader.SyntheticClassKind.FUNCTION.getId());
return Unit.INSTANCE;
}
});
@@ -34,17 +34,10 @@ fun extensionFunExpr() {
assertEquals(null, g.parameters.single().name)
}
fun customFunction() {
val f = object : Function<String> {}
assertNull(f.reflect())
}
fun box(): String {
lambda()
funExpr()
extensionFunExpr()
customFunction()
return "OK"
}
@@ -44,7 +44,6 @@ public final class JvmAnnotationNames {
public static final String KIND_FIELD_NAME = "k";
public static final String METADATA_DATA_FIELD_NAME = "d1";
public static final String METADATA_STRINGS_FIELD_NAME = "d2";
public static final String SYNTHETIC_CLASS_KIND_FIELD_NAME = "xi";
public static final String METADATA_MULTIFILE_CLASS_NAME_FIELD_NAME = "xs";
public static final String DATA_FIELD_NAME = "data";
public static final String STRINGS_FIELD_NAME = "strings";
@@ -44,9 +44,5 @@ class KotlinClassHeader(
}
}
enum class SyntheticClassKind(val id: Int) {
FUNCTION(1),
}
override fun toString() = "$kind version=$metadataVersion"
}
@@ -19,7 +19,6 @@
package kotlin.reflect.jvm
import org.jetbrains.kotlin.load.kotlin.JvmNameResolver
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
import org.jetbrains.kotlin.serialization.deserialization.MemberDeserializer
@@ -39,7 +38,6 @@ import kotlin.reflect.jvm.internal.getOrCreateModule
*/
fun <R> Function<R>.reflect(): KFunction<R>? {
val annotation = javaClass.getAnnotation(Metadata::class.java) ?: return null
if (annotation.xi != KotlinClassHeader.SyntheticClassKind.FUNCTION.id) return null
val input = BitEncoding.decodeBytes(annotation.d1).inputStream()
val nameResolver = JvmNameResolver(
JvmProtoBuf.StringTableTypes.parseDelimitedFrom(input, JvmProtoBufUtil.EXTENSION_REGISTRY), annotation.d2
+1 -10
View File
@@ -55,14 +55,5 @@ internal annotation class Metadata(
/**
* An extra string. For a multi-file part class, internal name of the facade class.
*/
val xs: String = "",
/**
* An extra integer. For a synthetic class, the specific kind of this class which is one of the following:
*
* 1 Anonymous class for a lambda or a function reference
*
* A value other than this (e.g. 0) or a missing value means this is a synthetic class of some other sort.
* This kind has no effect on the compiler because it doesn't read synthetic class metadata. It may be used in IDEs and tools.
*/
val xi: Int = 0
val xs: String = ""
)