I have a fairly complex data model where the base ...
# getting-started
m
I have a fairly complex data model where the base interface has a
@Composable operator fun invoke(): String = …
function. One of the sub interfaces is a
fun interface
and I was getting this runtime error whenever
invoke()
was called on an instance of that `fun interface`:
Copy code
java.lang.AbstractMethodError: abstract method "java.lang.String BaseInterface.invoke(androidx.compose.runtime.Composer, int)"
Using a standard
interface
instead of a
fun interface
solved the problem. AI reckons:
Copy code
The error occurred because the fun interface was trying to create a synthetic method that conflicted with the @Composable invoke() method from the parent interface. By making it a regular interface, we ensure proper inheritance of all methods from BaseInterface.
Is this a known issue? I can’t post the full data model here because it’s too much code, so I hope this is enough info.
d
cc @shikasd
s
Can you file a bug to Google issue tracker? I think this is new
m
Not sure, but it might be the same as this runtime exception:
Copy code
interface Foo {
    fun foo(): String = "foo"
}

fun interface Bar: Foo {
    operator fun invoke(): String
}

fun main() {
    val bar = Bar { "bar" }
    println("value: ${bar.foo()}") // "does not define or inherit an implementation of the resolved method 'abstract java.lang.String foo()'"
}
s
Yeah, looks the same
I am not sure how extending fun interfaces works tbh Although the second one is a bug on Kotlin side
m