SAM conversion on Kotlin Interfaces


From documentation:
SAM-conversions only work for Java methods, not supported for Kotlin functions, because Kotlin has nice functional types, and there’s no need for SAM conversion

But I could use them in one area. Lambdas do not support named arguments that well. With interfaces I can give more descriptive names to method and arguments. Also interfaces are better supported by documentation tools such as Dokka. That is really important for public API.

Also my code is written in Kotlin, but is consumed by Java users. People use it in combination with Java8 lambdas. With Kotlin lambdas IDE does not automatically add parameter names into Java8 lambdas. It works for interfaces.

So this forces me to use Java interfaces in Kotlin code. I would like to see SAM conversion enabled for Kotlin interfaces




And this:


Bump: using Kotlin through JNA’s Callback also requires explicit interfaces which I would prefer to back with regular lambdas instead of anonymous classes. My only solution right now is to use ugly anonymous classes with intelliJ’s "hide this because its ugly as ..." feature.