Skip properties from Java classes for which the getter type is unknown

thus avoiding NPE when auto-generating external serializers.

#KT-55681 Fixed
This commit is contained in:
Leonid Startsev
2023-01-02 20:48:58 +01:00
committed by Space Team
parent a1894ed027
commit 0b4f534d35
4 changed files with 41 additions and 1 deletions
@@ -74,7 +74,7 @@ internal fun serializablePropertiesForIrBackend(
if (irClass.isInternalSerializable) !it.annotations.hasAnnotation(SerializationAnnotations.serialTransientFqName)
else !DescriptorVisibilities.isPrivate(it.visibility) && ((it.isVar && !it.annotations.hasAnnotation(SerializationAnnotations.serialTransientFqName)) || primaryParamsAsProps.contains(
it
))
)) && it.getter?.returnType != null // For some reason, some properties from Java (like java.net.URL.hostAddress) do not have getter. Let's ignore them, as they never have worked properly in K1 either.
val (primaryCtorSerializableProps, bodySerializableProps) = properties
.asSequence()