I seem to have stumbled over an issue using inline classes to represent values in a delegate backing map. such fields don’t appear to be “dereferenceable”. Any help appreciated.
Kotlin 1.3.31
JDK 1.8.0_212 (AdoptOpenJDK)
package com.example.error
inline class FieldValue(val value: String)
class TestError {
enum class RequestFields {
ENUM_ONE
}
private data class RequestInputParameters(
private val backingMap: Map<RequestFields, FieldValue>
) : Map<RequestFields, FieldValue> by backingMap
companion object {
@JvmStatic
fun main(args: Array<String>) {
val testMap = mapOf(RequestFields.ENUM_ONE to FieldValue("value1")
)
val test = testMap[RequestFields.ENUM_ONE] // works!
println(test)
val testMap2 = RequestInputParameters(
mapOf(RequestFields.ENUM_ONE to FieldValue("value1"))
)
val test2 = testMap2[RequestFields.ENUM_ONE] // does not work :-(
println(test2)
}
}
}