Is there a known issue with inline classes that have a type
T
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
):
Copy code
@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 ->`works
a
Alexey Belkov [JB]
07/22/2021, 9:34 AM
I believe it's not a known issue, can you please file it to http://kotl.in/issue with a self-contained code sample to reproduce?
👍 1
e
eygraber
07/22/2021, 11:14 PM
I haven't been able to repro. I'm leaning towards blaming this on Android Studio's "apply changes" feature because nothing else makes any sense.