You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstract class AndroidLibAbstractClass<I1, I2, T> {
@Composable
abstract fun AComposableWithLambda(
input1: I1,
input2: I2,
hoistState: @Composable (T) -> Unit
): Unit
@Composable
abstract fun AComposableWithoutLambda(
input1: I1,
input2: I2,
): Unit
}
@Composable fun <I1, I2, T> AndroidLibComposableWithLambda(
i1: I1,
i2: I2,
objectWithComposables: AndroidLibAbstractClass<I1, I2, T>
): T? {
val payload: MutableState<T?> = remember { mutableStateOf(null) }
objectWithComposables.AComposableWithLambda(i1, i2) @Composable {
payload.value = it
}
return payload.value
}
@Composable fun <I1, I2, T> AndroidLibComposableWithoutLambda(
i1: I1,
i2: I2,
objectWithComposables: AndroidLibAbstractClass<I1, I2, T>
): Unit {
objectWithComposables.AComposableWithoutLambda(i1, i2)
}
Are defined in android-lib-module.
In the app module, a concrete child class of AndroidLibAbstractClasscan be used successfully in a Compose UI composition.
However, in the launchMolecule composition (see MethodResolutionTest) this fails on AndroidLibComposableWithLambda:
private class AndroidAppConcreteTestClass(
private val payload: String
) : AndroidLibAbstractClass<Unit, String, String>() {
@Composable
public override fun AComposableWithLambda(
input1: Unit,
input2: String,
hoistState: @Composable (s: String) -> Unit
) {
println("Can you hear me now? $payload")
hoistState(payload + input2)
}
@Composable
override fun AComposableWithoutLambda(
input1: Unit,
input2: String
) {
}
}
@Test fun testMethodResolution() {
val objectUnderTest = AndroidAppConcreteTestClass("a test")
val broadcastFrameClock = BroadcastFrameClock {}
val testScope = CoroutineScope(broadcastFrameClock)
val testFlow = testScope.launchMolecule {
AndroidLibComposableWithoutLambda(Unit, " again", objectUnderTest)
AndroidLibComposableWithLambda(Unit, " again", objectUnderTest)
}
assert(testFlow.value.contentEquals("a test again"))
}
because it gets an AbstractMethodError as it cannot resolve the concrete class's override at runtime?
Originally I thought it might be because I was using the 0.3.0-SNAPSHOT and the common KMP artifacts so I include a module with that example as well, but I was able to reproduce it with just 0.2.0 while all in Android/JVM.
The text was updated successfully, but these errors were encountered:
Surely this bug lies in the Compose compiler. I cannot see any way in which the code from Molecule could cause this. We're not involved in the compiler at all beyond telling it to apply the normal AndroidX Compose compiler plugin.
Reproducing project is here: https://github.com/steve-the-edwards/reproductions/tree/main/overridetest
Are defined in android-lib-module.
In the app module, a concrete child class of
AndroidLibAbstractClass
can be used successfully in a Compose UI composition.However, in the
launchMolecule
composition (seeMethodResolutionTest
) this fails onAndroidLibComposableWithLambda
:because it gets an AbstractMethodError as it cannot resolve the concrete class's override at runtime?
Originally I thought it might be because I was using the 0.3.0-SNAPSHOT and the common KMP artifacts so I include a module with that example as well, but I was able to reproduce it with just 0.2.0 while all in Android/JVM.
The text was updated successfully, but these errors were encountered: