Is there a known issue with inline classes that ha...
# announcements
e
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
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
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.
This issue fixed itself eventually, which makes me think it's related to https://youtrack.jetbrains.com/issue/KT-48010 which I just filed for a separate issue (same class though)