Issue with extension functions for generic receiver with multiple upper bounds


I was trying to implement extension function for generic receiver with multiple upper bounds, but received next compile error:

Error:(12, 23) Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun <T : InterfaceA> TestPresenter.getAsString(): String where T : InterfaceB defined in com.novachevskyi.kotlinextension

Source code for my example:

class TestPresenter : InterfaceA, InterfaceB {
    override val b: String = "test"
    override val a: Int = 10
interface InterfaceA {
    val a: Int
interface InterfaceB {
    val b: String

Extension function declaration:

fun <T> T.getAsString(): String
        where T : InterfaceA, T : InterfaceB =
            "Int value = $a, String value = $b"

And finally, I’m unable to perform a call for extension function described above:

val result = TestPresenter().getAsString()

Compiler can’t resolve reference of TestPresenter type:

Would appreciate for any help on how to resolve this issue.


It is a known issue, we hope to fix it in 1.1. You could track it here:


Thanks for the info!