Skip to content

Commit

Permalink
test: composable lambdas deep in generic types (#4370)
Browse files Browse the repository at this point in the history
testcase for compiler fix
#3466
  • Loading branch information
shishkin-pavel authored Feb 26, 2024
1 parent a5e57ae commit 2ca9e3c
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}


0 comments on commit 2ca9e3c

Please sign in to comment.