Make CLASS default class kind in binary metadata
Don't write the kind to the class file if it's CLASS to save some bytes
This commit is contained in:
@@ -239,13 +239,20 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
kind = KotlinClass.Kind.ANONYMOUS_OBJECT;
|
||||
}
|
||||
else if (isTopLevelOrInnerClass(descriptor)) {
|
||||
kind = KotlinClass.Kind.CLASS;
|
||||
// Default value is Kind.CLASS
|
||||
kind = null;
|
||||
}
|
||||
else {
|
||||
// LOCAL_CLASS is also written to inner classes of local classes
|
||||
kind = KotlinClass.Kind.LOCAL_CLASS;
|
||||
}
|
||||
|
||||
// Temporarily write class kind anyway because old compiler may not expect its absence
|
||||
// TODO: remove after M13
|
||||
if (kind == null) {
|
||||
kind = KotlinClass.Kind.CLASS;
|
||||
}
|
||||
|
||||
DescriptorSerializer serializer =
|
||||
DescriptorSerializer.create(descriptor, new JvmSerializerExtension(v.getSerializationBindings(), typeMapper));
|
||||
|
||||
@@ -257,11 +264,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
AnnotationVisitor av = v.getVisitor().visitAnnotation(asmDescByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_CLASS), true);
|
||||
av.visit(JvmAnnotationNames.ABI_VERSION_FIELD_NAME, JvmAbi.VERSION);
|
||||
av.visitEnum(
|
||||
JvmAnnotationNames.KIND_FIELD_NAME,
|
||||
Type.getObjectType(KotlinClass.KIND_INTERNAL_NAME).getDescriptor(),
|
||||
kind.toString()
|
||||
);
|
||||
//noinspection ConstantConditions
|
||||
if (kind != null) {
|
||||
av.visitEnum(
|
||||
JvmAnnotationNames.KIND_FIELD_NAME,
|
||||
Type.getObjectType(KotlinClass.KIND_INTERNAL_NAME).getDescriptor(),
|
||||
kind.toString()
|
||||
);
|
||||
}
|
||||
AnnotationVisitor array = av.visitArray(JvmAnnotationNames.DATA_FIELD_NAME);
|
||||
for (String string : BitEncoding.encodeBytes(SerializationUtil.serializeClassData(data))) {
|
||||
array.visit(null, string);
|
||||
|
||||
Reference in New Issue
Block a user