JS: serialize/deserialize type annotations similarly to JVM
No new tests added because there are some on extension functions, which soon will depend on type annotations to be preserved to work correctly
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,10 @@ extend Callable.ValueParameter {
|
|||||||
repeated Annotation parameter_annotation = 130;
|
repeated Annotation parameter_annotation = 130;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extend Type {
|
||||||
|
repeated Annotation type_annotation = 130;
|
||||||
|
}
|
||||||
|
|
||||||
message Classes {
|
message Classes {
|
||||||
// id in StringTable
|
// id in StringTable
|
||||||
repeated int32 class_name = 1 [packed = true];
|
repeated int32 class_name = 1 [packed = true];
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -58,8 +58,8 @@ class KotlinJavascriptAnnotationAndConstantLoader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun loadTypeAnnotations(proto: ProtoBuf.Type, nameResolver: NameResolver): List<AnnotationDescriptor> {
|
override fun loadTypeAnnotations(proto: ProtoBuf.Type, nameResolver: NameResolver): List<AnnotationDescriptor> {
|
||||||
// TODO: support type annotations for js descriptors
|
val annotations = proto.getExtension(JsProtoBuf.typeAnnotation).orEmpty()
|
||||||
return listOf()
|
return annotations.map { proto -> deserializer.deserializeAnnotation(proto, nameResolver) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadPropertyConstant(
|
override fun loadPropertyConstant(
|
||||||
|
|||||||
+16
-4
@@ -16,11 +16,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.serialization.js
|
package org.jetbrains.kotlin.serialization.js
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||||
import org.jetbrains.kotlin.resolve.constants.NullValue
|
import org.jetbrains.kotlin.resolve.constants.NullValue
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
import org.jetbrains.kotlin.serialization.AnnotationSerializer
|
||||||
import org.jetbrains.kotlin.serialization.*
|
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||||
|
import org.jetbrains.kotlin.serialization.SerializerExtension
|
||||||
|
import org.jetbrains.kotlin.serialization.StringTable
|
||||||
|
import org.jetbrains.kotlin.types.JetType
|
||||||
|
|
||||||
public object KotlinJavascriptSerializerExtension : SerializerExtension() {
|
public object KotlinJavascriptSerializerExtension : SerializerExtension() {
|
||||||
override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder, stringTable: StringTable) {
|
override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder, stringTable: StringTable) {
|
||||||
@@ -54,4 +60,10 @@ public object KotlinJavascriptSerializerExtension : SerializerExtension() {
|
|||||||
proto.addExtension(JsProtoBuf.parameterAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable))
|
proto.addExtension(JsProtoBuf.parameterAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
override fun serializeType(type: JetType, proto: ProtoBuf.Type.Builder, stringTable: StringTable) {
|
||||||
|
for (annotation in type.getAnnotations()) {
|
||||||
|
proto.addExtension(JsProtoBuf.typeAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user