Hello I have an interface like the following. For some reason, if I try to pass a method reference like
MyJavaClass::hasData
as an
IsStateRunningCheck
argument I get the following error. Found KFunction1 and not my interface. Is this an instance of SAM conversion not working properly or is there something I can do to make this possible.
fun myFooMethod(stateCheck: IsStateRunnningCheck<Int>) { ... }
fun test() {
myFooMethod(MyJavaClass::hasData) // fails to compile
myFooMyethod( { it.hasData() }) // works fine
}
// I don't think it matters if this is java or not
class MyJavaClass<Int> {
boolean hasData(int x) { return true; }
}
e
E.Kisaragi
04/23/2020, 5:06 PM
SAM is 1.4 or later IIRC
j
Justin Breitfeller
04/23/2020, 6:09 PM
Gotcha thank you. I thought it had something but maybe not.
Justin Breitfeller
04/23/2020, 6:13 PM
Actually, looking at it again, we have a Java interface and from what I understand Kotlin 1.4 is only adding SAM conversion for Kotlin interfaces. How I read it is 1.3 should already support Java SAM conversion