Blake Anderson
08/07/2024, 5:26 AMKFunction
reference to one of the overloads? I found I can use val ref: (String) -> Unit
, for instance, as a way to disambiguate but the resulting type is not KFunction
. It seems like I can cast this without everything crashing, but it's messy to use and not sure how stable that is.Sam
08/07/2024, 5:32 AMreflect()
function that should get you a KFunction from it. That's the first thing that comes to mind; there might be a better solutionephemient
08/07/2024, 6:20 AMephemient
08/07/2024, 6:21 AMBlake Anderson
08/07/2024, 7:18 AMwhere
is a good trick there; I came up with the rest of it as well but still needed a raw cast to KFunction
. It's still a little messy due to requiring _
for the return type (TypeScript's infer comes to mind here), but overall works out. I had tried using T : Function<R>
to allow the generic type to be written as a lambda (also effectively working for any arity) but it doesn't quite work because Kotlin doesn't allow multiple restrictions in where
if one of them is another generic type.ephemient
08/07/2024, 8:47 AM