reified function is useful, but it can't be called from Java.
h
Hanno
02/29/2020, 10:41 AM
If you need it, you should use it. If you need to support java clients, an overload that takes a class is generally sufficient to be "good". Your reified function can then call the overload as well and pass in T::class
c
Chills
02/29/2020, 10:42 AM
i have T::class
instead of Class<T>
Chills
02/29/2020, 10:42 AM
as T reified
h
Hanno
02/29/2020, 1:32 PM
Yep. If you have to support java clients, go to your method that takes reified type, extract the whole Body, extract T::class there as a Parameter of type Class<T> and you have one version that takes class, one version without parameter using reification. If that's too complicated and you must not support java Clients, forget what i Said ;)
z
Zach Klippenstein (he/him) [MOD]
02/29/2020, 9:06 PM
It can still be a good idea to extract large functions into non-reified functions with a reified wrapper even if you don't call it from java, since inline function bodies get copied into their call sites, so if you're making a lot of calls to large inline functions it can unnecessarily bloat your bytecode size.
h
Hanno
03/01/2020, 9:54 AM
Nice hint, that's true, didn't think about that :)