Increase priority of @ContextualSerialization annotation on types

This commit is contained in:
Leonid Startsev
2018-11-22 17:05:50 +03:00
parent f13f54d5ad
commit 7e32e2e9b9
@@ -101,13 +101,13 @@ fun AbstractSerialGenerator.findTypeSerializerOrContext(
if (annotations.hasAnnotation(SerializationAnnotations.contextualFqName) || kType in contextualKClassListInCurrentFile)
module.getClassFromSerializationPackage(SpecialBuiltins.contextSerializer)
else
throw CompilationException(
"Serializer for element of type $kType has not been found.\n" +
"To use context serializer as fallback, explicitly annotate element with @ContextualSerializer",
null,
sourceElement
)
return findTypeSerializer(module, kType) ?: getContextualSerializer()
null
return getContextualSerializer() ?: findTypeSerializer(module, kType) ?: throw CompilationException(
"Serializer for element of type $kType has not been found.\n" +
"To use context serializer as fallback, explicitly annotate element with @ContextualSerializer",
null,
sourceElement
)
}
fun findTypeSerializer(module: ModuleDescriptor, kType: KotlinType): ClassDescriptor? {