Browse Source

test: composable lambdas deep in generic types (#4370)

testcase for compiler fix
https://github.com/JetBrains/compose-multiplatform/issues/3466
pull/4376/head
Shishkin Pavel 9 months ago committed by GitHub
parent
commit
2ca9e3c973
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 38
      compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CollectionOfComposablesTests.kt

38
compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CollectionOfComposablesTests.kt

@ -86,6 +86,44 @@ class CollectionOfComposablesTests {
actual = root.dump()
)
}
/** Composable lambdas nested more than single level deep in generic types provoke compilation failure for K/Native
* https://github.com/JetBrains/compose-multiplatform/issues/3466
*/
@Test
fun testNestedComposableTypes() = runTest {
data class Container<T>(val value: T)
class DoubleNested(
val f: List<Container<@Composable () -> Unit>>,
)
class SingleNested(
val f: List<@Composable () -> Unit>,
)
val composables: List<@Composable () -> Unit> = listOf(@Composable { TextLeafNode("a") }, @Composable { TextLeafNode("b") })
val single = SingleNested(composables)
val singleRoot = composeText {
for (c in single.f) {
c()
}
}
val double = DoubleNested(composables.map { Container(it) })
val doubleRoot = composeText {
for (c in double.f.map { it.value }) {
c()
}
}
assertEquals(
expected = "root:{a, b}",
actual = singleRoot.dump()
)
assertEquals(singleRoot.dump(), doubleRoot.dump())
}
}

Loading…
Cancel
Save