Avoid recursive type refinement
Recursion happens in kotlinx.serialization project https://github.com/Kotlin/kotlinx.serialization/blob/5e8ccad1f70a9457e0ffe6ae6b10a0bd0eaaa618/formats/json-tests/commonTest/src/kotlinx/serialization/json/JsonCustomSerializersTest.kt#L37 @Serializable data class C(@Id(1) val a: Int = 31, @Id(2) val b: Int = 42) { @Serializer(forClass = C::class) companion object : KSerializer<C> { override fun serialize(encoder: Encoder, value: C) { // } } } #KT-53157
This commit is contained in:
committed by
teamcity
parent
c726360ad2
commit
34779029f3
@@ -77,6 +77,7 @@ class KotlinTypeRefinerImpl(
|
|||||||
@TypeRefinement
|
@TypeRefinement
|
||||||
override fun refineType(type: KotlinTypeMarker): KotlinType {
|
override fun refineType(type: KotlinTypeMarker): KotlinType {
|
||||||
require(type is KotlinType)
|
require(type is KotlinType)
|
||||||
|
if (type.constructor.declarationDescriptor?.module == moduleDescriptor) return type
|
||||||
return when {
|
return when {
|
||||||
!type.needsRefinement() -> type
|
!type.needsRefinement() -> type
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user