Davide Giuseppe Farella
03/28/2019, 11:29 PMfun MutableEntity.postSomething() = postSomething
bdawg.io
03/28/2019, 11:34 PM(mutableEntity as LockedEntity).postSomething()
Davide Giuseppe Farella
03/28/2019, 11:39 PMbdawg.io
03/28/2019, 11:42 PMDavide Giuseppe Farella
03/28/2019, 11:53 PMScope
, in that case it will obviously work, also without any casting.
Outside of a Scope
class I can't see how it could work 🤔spragg
03/28/2019, 11:56 PMpublic static final void main() {
MutableEntity var0 = new MutableEntity();
int var2 = false;
var0.postSomething1((LockedEntity)var0);
}
spragg
03/28/2019, 11:59 PMwhen
is compiled it casts the variable which is unpacked. In this case, the compiler is able to cast the variable to the correct parent interface to allow the function.spragg
03/29/2019, 12:00 AMinterface Scope {
fun postSomething()
}
spragg
03/29/2019, 12:19 AMDavide Giuseppe Farella
03/29/2019, 6:47 AM>>If you change the Scope interface with something like this. it would also work.
interface Scope {
fun postSomething()
}
Yes, it will work but I don't have any reference to the entity for work with 😅
In my scenario my entity wraps an Android LiveData
and I want reproduce something like that:Davide Giuseppe Farella
03/29/2019, 6:49 AMDavide Giuseppe Farella
03/29/2019, 6:51 AM