eygraber
07/22/2021, 5:16 AMT
where an inlined property that uses a with
scope on an instance of the same type as T
gets unwrapped to use the class instance instead of the actual one?
Something like (using custom extensions on JsonObject
):
@JvmInline
value class MyJson(val json: JsonObject) {
inline val type
get() = with(json.jsonObject("type") {
string("actual_type") // this crashes at runtime because it is looking for this field in the json property instead of the one from the with scope
}
}
Switching to `json.jsonObject("type").let { type ->`worksAlexey Belkov [JB]
07/22/2021, 9:34 AMeygraber
07/22/2021, 11:14 PMeygraber
08/01/2021, 10:49 PM