Passing lambda instead of interface

As @zsmb13 said, SAM conversions are only supported for Java interfaces.

You could create an extension function to make it work though:

// Assuming the type of dataManager is DataManager.
fun DataManager.createAndSubmitSendIt(title: String, 
                                      message: String, 
                                      progressListener: (Long) -> Unit) {
    createAndSubmitSendIt(title, message,
        object : ProgressListener {
            override fun transferred(bytesUploaded: Long) {
                progressListener(bytesUploaded)
            }
        })
}

Edit

Kotlin 1.4 introduced function interfaces that enable SAM conversions for interfaces defined in Kotlin. This means that you can call your function with a lambda if you define your interface with the fun keyword. Like this:

fun interface ProgressListener {
    fun transferred(bytesUploaded: Long)
}

Update: you need to use a fun interface to support SAM conversions, which let you pass in a lambda as the implementation of an interface.

Old answer below.


Kotlin only supports SAM conversions for Java interfaces.

... note that this feature works only for Java interop; since Kotlin has proper function types, automatic conversion of functions into implementations of Kotlin interfaces is unnecessary and therefore unsupported.

-- Official documentation

If you want to use a lambda in the parameter, make your function take a function parameter instead of an interface. (For now at least. Supporting SAM conversions for Kotlin interfaces is an ongoing discussion, it was one of the possible future features at the Kotlin 1.1 live stream.)

Tags:

Lambda

Kotlin