diff --git a/kotlin-spark-api/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Encoding.kt b/kotlin-spark-api/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Encoding.kt index 56230dff..a123c0c0 100644 --- a/kotlin-spark-api/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Encoding.kt +++ b/kotlin-spark-api/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Encoding.kt @@ -463,8 +463,24 @@ object KotlinTypeInference { ) } - currentType.isSubtypeOf?>() -> TODO() - currentType.isSubtypeOf?>() -> TODO() + currentType.isSubtypeOf?>() || currentType.isSubtypeOf?>() -> { + val keyEncoder = encoderFor( + currentType = tArguments[0].type!!, + seenTypeSet = seenTypeSet, + typeVariables = typeVariables, + ) + val valueEncoder = encoderFor( + currentType = tArguments[1].type!!, + seenTypeSet = seenTypeSet, + typeVariables = typeVariables, + ) + AgnosticEncoders.MapEncoder( + /* clsTag = */ ClassTag.apply>(jClass), + /* keyEncoder = */ keyEncoder, + /* valueEncoder = */ valueEncoder, + /* valueContainsNull = */ tArguments[1].type!!.isMarkedNullable, + ) + } kClass.isData -> { if (currentType in seenTypeSet) throw IllegalStateException("Circular reference detected for type $currentType")