Jack Darlington
01/18/2021, 9:26 PMinterface I {
}
class C: I {
var x: String by someDelegate()
}
class T {
var i: I = C()
}
T().i::x.getDelegate()
-> returns null
C()::x.getDelegate()
-> returns the someDelegate instanceNir
01/18/2021, 10:07 PMNir
01/18/2021, 10:07 PMNir
01/18/2021, 10:08 PMT().i
can be cast to a CNir
01/18/2021, 10:09 PMT().i::x.getDelegate()
and then ask it to give you back something if the instance there happens to have an x
, you'd need to do the cast to a known derived interface/class that has an x
Nir
01/18/2021, 10:09 PMNir
01/18/2021, 10:09 PMJack Darlington
01/18/2021, 10:21 PMNir
01/18/2021, 10:22 PMNir
01/18/2021, 10:22 PMNir
01/18/2021, 10:22 PMNir
01/18/2021, 10:24 PMNir
01/18/2021, 10:25 PMNir
01/18/2021, 10:26 PMJack Darlington
01/18/2021, 10:29 PMNir
01/18/2021, 10:31 PMx
, and you can do this for as many fields as you wantNir
01/18/2021, 10:31 PMNir
01/18/2021, 10:32 PMMap<String, Any>
at some point, and then operate on that instead? That's basically what you're asking forYoussef Shoaib [MOD]
01/18/2021, 10:40 PM(T().i as C)::x.getDelegate()