Remove non-type annotations from type serializer analysis

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/450
This commit is contained in:
Leonid Startsev
2019-05-22 12:53:43 +03:00
parent 728459a504
commit 9ce1f843e3
4 changed files with 3 additions and 7 deletions
@@ -83,7 +83,7 @@ fun AbstractSerialGenerator.getSerialTypeInfo(property: SerializableProperty): S
}
else -> {
val serializer =
findTypeSerializerOrContext(property.module, property.type, property.descriptor.annotations, property.descriptor.findPsi())
findTypeSerializerOrContext(property.module, property.type, property.descriptor.findPsi())
SerializableInfo(serializer)
}
}
@@ -108,11 +108,11 @@ fun analyzeSpecialSerializers(
fun AbstractSerialGenerator.findTypeSerializerOrContext(
module: ModuleDescriptor,
kType: KotlinType,
annotations: Annotations = kType.annotations,
sourceElement: PsiElement? = null
): ClassDescriptor? {
val annotations = kType.annotations
if (kType.isTypeParameter()) return null
if (kType.isMarkedNullable) return findTypeSerializerOrContext(module, kType.makeNotNullable(), annotations, sourceElement)
if (kType.isMarkedNullable) return findTypeSerializerOrContext(module, kType.makeNotNullable(), sourceElement)
annotations.serializableWith(module)?.let { return it.toClassDescriptor }
additionalSerializersInScopeOfCurrentFile[kType]?.let { return it }
if (kType in contextualKClassListInCurrentFile) return module.getClassFromSerializationPackage(SpecialBuiltins.contextSerializer)
@@ -451,7 +451,6 @@ interface IrBuilderExtension {
?: if (!property.type.isTypeParameter()) generator.findTypeSerializerOrContext(
property.module,
property.type,
property.descriptor.annotations,
property.descriptor.findPsi()
) else null
return serializerInstance(
@@ -124,7 +124,6 @@ internal fun SerializerJsTranslator.serializerTower(property: SerializableProper
?: if (!property.type.isTypeParameter()) findTypeSerializerOrContext(
property.module,
property.type,
property.descriptor.annotations,
property.descriptor.findPsi()
) else null
return serializerInstance(serializer, property.module, property.type, property.genericIndex)
@@ -191,7 +191,6 @@ internal fun InstructionAdapter.stackValueSerializerInstanceFromSerializerWithou
?: if (!property.type.isTypeParameter()) serializerCodegen.findTypeSerializerOrContext(
property.module,
property.type,
property.descriptor.annotations,
property.descriptor.findPsi()
) else null
return serializerCodegen.stackValueSerializerInstance(
@@ -382,7 +381,6 @@ fun AbstractSerialGenerator.getSerialTypeInfo(property: SerializableProperty, ty
?: findTypeSerializerOrContext(
property.module,
property.type,
property.descriptor.annotations,
property.descriptor.findPsi()
)
return JVMSerialTypeInfo(