Skip to content

Commit edae78a

Browse files
KT-84055 verification (#5539)
test for KT-84055 added to compose compiler testsuite ## Testing autotest added ## Release Notes N/A
1 parent be0c408 commit edae78a

File tree

2 files changed

+33
-0
lines changed
  • compose/integrations/composable-test-cases/testcases/lambdas

2 files changed

+33
-0
lines changed

compose/integrations/composable-test-cases/testcases/lambdas/lib/src/commonMain/kotlin/Dependencies.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,18 @@ fun ComposableAlwaysReturnsNullUnit(): Unit? {
2929
@Composable
3030
fun ComposableAlwaysReturnsUnit(): Unit? {
3131
return Unit
32+
}
33+
34+
fun interface Decorator {
35+
@Composable
36+
fun Decoration(innerElement: @Composable () -> Unit)
37+
}
38+
39+
@Composable
40+
fun WithDecoration(content: @Composable () -> Unit, decorator: Decorator? = null) {
41+
if (decorator != null) {
42+
decorator.Decoration { content() }
43+
} else {
44+
content()
45+
}
3246
}

compose/integrations/composable-test-cases/testcases/lambdas/main/src/commonTest/kotlin/Tests.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ class Tests {
142142
}
143143
assertEquals("root:{Value = Unit}", root.dump())
144144
}
145+
146+
@Composable
147+
private fun SimpleDecoration(inner: @Composable () -> Unit) {
148+
TextLeafNode("inside decoration")
149+
inner()
150+
}
151+
152+
// KT-84055
153+
@Test
154+
fun testSamConversion() {
155+
val root = composeText() {
156+
WithDecoration(
157+
content = { TextLeafNode("Content") },
158+
decorator = { inner ->
159+
SimpleDecoration(inner)
160+
})
161+
}
162+
assertEquals("root:{inside decoration, Content}", root.dump())
163+
}
145164
}
146165

147166
private fun someText(): String {

0 commit comments

Comments
 (0)