File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
compose/integrations/composable-test-cases/testcases/lambdas
lib/src/commonMain/kotlin
main/src/commonTest/kotlin Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -29,4 +29,18 @@ fun ComposableAlwaysReturnsNullUnit(): Unit? {
2929@Composable
3030fun 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}
Original file line number Diff line number Diff 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
147166private fun someText (): String {
You can’t perform that action at this time.
0 commit comments