it does: <https://kotlinlang.org/docs/reference/ja...
# random
r
ah... nice 🙂 since when?
p
I am pretty sure it worked in 1.2
r
hm... have to check again in this case, thanks
g
It was available before 1.0
But Kotlin doesn't have SAM conversion for own interfaces, only for Java ones, but probably it will be available later
r
ah... maybe that was the thing
g
Usually you don't need SAM for Kotlin types, because you can use lambda type declaration, at least it was original idea of the language authors
r
I remember having an issue with Kotlin/Java combination where it did not work as expected and which made me believe kotlin does not support SAM conversion
g
But for compatibility of Kotlin libraries with Java and to remove typealias boilerplate to name interfaces it may be useful tho
It may not work in some specific cases, most of them should be fixed with new type inference. If you have particular example, please share it
r
I don't have one currently
l
With new type inference in 1.3 (that is currently opt-in), you can already have lambda conversion for Kotlin SAM IIRC
g
@louiscad Really? Interesting, I never tried. I thought that for backward compatibility Kotlin SAM will require some special annotation or keyword (I saw
sam interface
proposal in one of JB talks) Is it just wors for Kotlin types?
l
@gildor I think so. That's what I remember reading and hearing at Svetlana's 2018 KotlinConf talk. I've not checked because I found satisfying workarounds to this limitation before 1.3 and I haven't needed it recently though.
g
What kind workaround?
Hmm, this is slide from Svetlana’s talk, there is no Kotlin example, only Java one
As I understand, this example only about cases when you have Java type in declaration of Kotlin method, so you have SAM, which is doesn’t work now (you have to decleare
Action<String> {}
) But SAM for Kotlin interfaces still not working, because as I remember to keep backward compatibility it requires additional marker for SAM
l
You're right, I guess they plan to provide an annotation for this so it is explicit, or maybe it's already available when new type inference is enabled?
g
This is a slide from quite old (pre 1.3) presentation about upcoming 1.3 features also mentiones SAM for Kotlin types (but apparently it is not ready on 1.3.20, maybe later, maybe 1.4)
👍 1