Increase priority of @ContextualSerialization annotation on types
This commit is contained in:
+7
-7
@@ -101,13 +101,13 @@ fun AbstractSerialGenerator.findTypeSerializerOrContext(
|
|||||||
if (annotations.hasAnnotation(SerializationAnnotations.contextualFqName) || kType in contextualKClassListInCurrentFile)
|
if (annotations.hasAnnotation(SerializationAnnotations.contextualFqName) || kType in contextualKClassListInCurrentFile)
|
||||||
module.getClassFromSerializationPackage(SpecialBuiltins.contextSerializer)
|
module.getClassFromSerializationPackage(SpecialBuiltins.contextSerializer)
|
||||||
else
|
else
|
||||||
throw CompilationException(
|
null
|
||||||
"Serializer for element of type $kType has not been found.\n" +
|
return getContextualSerializer() ?: findTypeSerializer(module, kType) ?: throw CompilationException(
|
||||||
"To use context serializer as fallback, explicitly annotate element with @ContextualSerializer",
|
"Serializer for element of type $kType has not been found.\n" +
|
||||||
null,
|
"To use context serializer as fallback, explicitly annotate element with @ContextualSerializer",
|
||||||
sourceElement
|
null,
|
||||||
)
|
sourceElement
|
||||||
return findTypeSerializer(module, kType) ?: getContextualSerializer()
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findTypeSerializer(module: ModuleDescriptor, kType: KotlinType): ClassDescriptor? {
|
fun findTypeSerializer(module: ModuleDescriptor, kType: KotlinType): ClassDescriptor? {
|
||||||
|
|||||||
Reference in New Issue
Block a user