diesieben07
03/11/2018, 5:44 PMfun <T> bind(type: Class<T>, instance: T)
fun <T> bind(type: Class<T>, factory: Function<T>)
Calling it like this fails with "Cannot choose among the following candidates without completing type inference":
bind(MyClass::class.java, { p: String -> MyClass(p) })
Why is this? Using a reference instead of a lambda (bind(MyClass::class.java, ::MyClass)
) works fine. What am I missing here?Andreas Sinz
03/11/2018, 5:48 PMdiesieben07
03/11/2018, 5:49 PMMyClass
, no?Andreas Sinz
03/11/2018, 5:49 PMT
or a Function<T>
diesieben07
03/11/2018, 5:50 PMT
, since T
is MyClass
...bindInstance
šAndreas Sinz
03/11/2018, 5:55 PMdiesieben07
03/11/2018, 5:55 PMAndreas Sinz
03/11/2018, 6:01 PMFunction<T>
? the java one?diesieben07
03/11/2018, 6:05 PMkotlin.Function
Andreas Sinz
03/11/2018, 6:16 PMkotlin.Function
rather than a Function Type?T
is, your code works bind<MyClass>(MyClass::class.java, ...)
(but then you have MyClass
3 times in the same line š¬diesieben07
03/11/2018, 6:26 PMkotlin.Function
is because I want to be able to pass a function with any number of parameters.