Hi, I have a doubt about Kotlin lazy property dele...
# android
j
Hi, I have a doubt about Kotlin lazy property delegation For example, this property delegate with lazy:
val x: String by lazy{...}
When I decompile the Kotlin code into Java code, I see that the getX() method is not ultimately called this method
public inline operator fun <T> Lazy<T>.getValue(thisRef: Any?, property: KProperty<*>): T = value
It is the getter method of value, which is
getValue()
instead of
getValue(thisRef: Any?, property: KProperty<*>)
So, I don’t understand how the method
getValue(thisRef: Any?, property: KProperty<*>)
is called during the execution of lazy
đź‘€ 1
image.png
Copy code
val map2: MutableMap<String, Any?> = mutableMapOf("age" to "Jay", "name" to "18")
var age: Int? by map2



@Nullable
public final Integer getAge() {
   Map var1 = this.age$delegate;
   KProperty var3 = $$delegatedProperties[1];
   boolean var4 = false;
   return (Integer)MapsKt.getOrImplicitDefaultNullable(var1, var3.getName());
}

public final void setAge(@Nullable Integer var1) {
   Map var2 = this.age$delegate;
   KProperty var4 = $$delegatedProperties[1];
   boolean var5 = false;
   var2.put(var4.getName(), var1);
}
And Map delegation has the same confusion
e
j
Thanks for the tip @ephemient