Avoid reallocating capture-less composable lambdas, deprecate emptyContent and orEmpty helpers
Fixes: 177330775
Relnote: "emptyContent() and (@Composable () -> Unit).orEmpty() utilities have been deprecated as they no longer have any positive performance impact or value"
Change-Id: I0484d3ef439993d05eea86e53f05997eced590ab
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/AbstractIrTransformTest.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/AbstractIrTransformTest.kt
index 6dcaf71..b022954 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/AbstractIrTransformTest.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/AbstractIrTransformTest.kt
@@ -220,13 +220,16 @@
) {
"${it.groupValues[1]}<>"
}
- // composableLambdaInstance(<>, true)
+ // composableLambdaInstance(<>, true, )
.replace(
Regex(
- "(composableLambdaInstance\\()([-\\d]+)"
+ "(composableLambdaInstance\\()([-\\d]+, (true|false), (null|\"(.*)\")\\))"
)
) {
- "${it.groupValues[1]}<>"
+ val callStart = it.groupValues[1]
+ val tracked = it.groupValues[3]
+ val sourceInfo = it.groupValues[5]
+ "$callStart<>, $tracked, \"${generateSourceInfo(sourceInfo, source)}\")"
}
// composableLambda(%composer, <>, true)
.replace(
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ClassStabilityTransformTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ClassStabilityTransformTests.kt
index 90d06fb..834c976 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ClassStabilityTransformTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ClassStabilityTransformTests.kt
@@ -753,7 +753,13 @@
@Composable
fun C(items: List<String>, %composer: Composer?, %changed: Int) {
%composer.startRestartGroup(<>, "C(C)<X(item...>:Test.kt")
- X(items, composableLambda(%composer, <>, true, "C<A(item...>,<A(Wrap...>:Test.kt") { item: String, %composer: Composer?, %changed: Int ->
+ X(items, ComposableSingletons%TestKt.lambda-1, %composer, 0b1000)
+ %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
+ C(items, %composer, %changed or 0b0001)
+ }
+ }
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function3<String, Composer, Int, Unit> = composableLambdaInstance(<>, false, "C<A(item...>,<A(Wrap...>:Test.kt") { item: String, %composer: Composer?, %changed: Int ->
val %dirty = %changed
if (%changed and 0b1110 === 0) {
%dirty = %dirty or if (%composer.changed(item)) 0b0100 else 0b0010
@@ -764,9 +770,6 @@
} else {
%composer.skipToGroupEnd()
}
- }, %composer, 0b00111000)
- %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
- C(items, %composer, %changed or 0b0001)
}
}
"""
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamSignatureTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamSignatureTests.kt
index 73b71ef..4591ad7 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamSignatureTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ComposerParamSignatureTests.kt
@@ -42,11 +42,27 @@
// and one for the content lambda passed into Foo. Importantly, there is no lambda for
// the content lambda's restart group because we are using the lambda itself.
"""
+ public final class ComposableSingletons%TestKt {
+ public final static LComposableSingletons%TestKt; INSTANCE
+ public <init>()V
+ public static Lkotlin/jvm/functions/Function2; lambda-1
+ public final getLambda-1%test_module()Lkotlin/jvm/functions/Function2;
+ final static INNERCLASS ComposableSingletons%TestKt%lambda-1%1 null null
+ static <clinit>()V
+ }
+ final class ComposableSingletons%TestKt%lambda-1%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function2 {
+ <init>()V
+ public final invoke(Landroidx/compose/runtime/Composer;I)V
+ public final static LComposableSingletons%TestKt%lambda-1%1; INSTANCE
+ public synthetic bridge invoke(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
+ static <clinit>()V
+ final static INNERCLASS ComposableSingletons%TestKt%lambda-1%1 null null
+ OUTERCLASS ComposableSingletons%TestKt <clinit> ()V
+ }
public final class TestKt {
final static INNERCLASS TestKt%Foo%1 null null
public final static Foo(Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V
final static INNERCLASS TestKt%Bar%1 null null
- final static INNERCLASS TestKt%Bar%2 null null
public final static Bar(Landroidx/compose/runtime/Composer;I)V
}
final class TestKt%Foo%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function2 {
@@ -59,20 +75,11 @@
OUTERCLASS TestKt Foo (Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V
}
final class TestKt%Bar%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function2 {
- <init>()V
- public final invoke(Landroidx/compose/runtime/Composer;I)V
- public final static LTestKt%Bar%1; INSTANCE
- public synthetic bridge invoke(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
- static <clinit>()V
- final static INNERCLASS TestKt%Bar%1 null null
- OUTERCLASS TestKt Bar (Landroidx/compose/runtime/Composer;I)V
- }
- final class TestKt%Bar%2 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function2 {
<init>(I)V
public final invoke(Landroidx/compose/runtime/Composer;I)V
final synthetic I %%changed
public synthetic bridge invoke(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
- final static INNERCLASS TestKt%Bar%2 null null
+ final static INNERCLASS TestKt%Bar%1 null null
OUTERCLASS TestKt Bar (Landroidx/compose/runtime/Composer;I)V
}
"""
@@ -636,12 +643,28 @@
}
""",
"""
+ public final class ComposableSingletons%TestKt {
+ public final static LComposableSingletons%TestKt; INSTANCE
+ public <init>()V
+ public static Lkotlin/jvm/functions/Function3; lambda-1
+ public final getLambda-1%test_module()Lkotlin/jvm/functions/Function3;
+ final static INNERCLASS ComposableSingletons%TestKt%lambda-1%1 null null
+ static <clinit>()V
+ }
+ final class ComposableSingletons%TestKt%lambda-1%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function3 {
+ <init>()V
+ public final invoke(ILandroidx/compose/runtime/Composer;I)V
+ public final static LComposableSingletons%TestKt%lambda-1%1; INSTANCE
+ public synthetic bridge invoke(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
+ static <clinit>()V
+ final static INNERCLASS ComposableSingletons%TestKt%lambda-1%1 null null
+ OUTERCLASS ComposableSingletons%TestKt <clinit> ()V
+ }
public final class TestKt {
private final static Lkotlin/jvm/functions/Function3; foo
public final static getFoo()Lkotlin/jvm/functions/Function3;
final static INNERCLASS TestKt%Bar%1 null null
public final static Bar(Landroidx/compose/runtime/Composer;I)V
- final static INNERCLASS TestKt%foo%1 null null
static <clinit>()V
}
final class TestKt%Bar%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function2 {
@@ -652,15 +675,6 @@
final static INNERCLASS TestKt%Bar%1 null null
OUTERCLASS TestKt Bar (Landroidx/compose/runtime/Composer;I)V
}
- final class TestKt%foo%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function3 {
- <init>()V
- public final invoke(ILandroidx/compose/runtime/Composer;I)V
- public final static LTestKt%foo%1; INSTANCE
- public synthetic bridge invoke(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
- static <clinit>()V
- final static INNERCLASS TestKt%foo%1 null null
- OUTERCLASS TestKt <clinit> ()V
- }
"""
)
@@ -674,19 +688,26 @@
}
""",
"""
- public final class TestKt {
- final static INNERCLASS TestKt%Bar%foo%1 null null
- final static INNERCLASS TestKt%Bar%1 null null
- public final static Bar(Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V
+ public final class ComposableSingletons%TestKt {
+ public final static LComposableSingletons%TestKt; INSTANCE
+ public <init>()V
+ public static Lkotlin/jvm/functions/Function3; lambda-1
+ public final getLambda-1%test_module()Lkotlin/jvm/functions/Function3;
+ final static INNERCLASS ComposableSingletons%TestKt%lambda-1%1 null null
+ static <clinit>()V
}
- final class TestKt%Bar%foo%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function3 {
+ final class ComposableSingletons%TestKt%lambda-1%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function3 {
<init>()V
public final invoke(ILandroidx/compose/runtime/Composer;I)V
- public final static LTestKt%Bar%foo%1; INSTANCE
+ public final static LComposableSingletons%TestKt%lambda-1%1; INSTANCE
public synthetic bridge invoke(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
static <clinit>()V
- final static INNERCLASS TestKt%Bar%foo%1 null null
- OUTERCLASS TestKt Bar (Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V
+ final static INNERCLASS ComposableSingletons%TestKt%lambda-1%1 null null
+ OUTERCLASS ComposableSingletons%TestKt <clinit> ()V
+ }
+ public final class TestKt {
+ final static INNERCLASS TestKt%Bar%1 null null
+ public final static Bar(Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V
}
final class TestKt%Bar%1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function2 {
<init>(Lkotlin/jvm/functions/Function2;I)V
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTests.kt
index 68df589..99b592d 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTests.kt
@@ -2311,13 +2311,7 @@
fun Test(%composer: Composer?, %changed: Int) {
%composer.startRestartGroup(<>, "C(Test)<W>:Test.kt")
if (%changed !== 0 || !%composer.skipping) {
- W(composableLambda(%composer, <>, true, "C<A()>:Test.kt") { %composer: Composer?, %changed: Int ->
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- A(%composer, 0)
- } else {
- %composer.skipToGroupEnd()
- }
- }, %composer, 0b0110)
+ W(ComposableSingletons%TestKt.lambda-1, %composer, 0)
} else {
%composer.skipToGroupEnd()
}
@@ -2325,6 +2319,15 @@
Test(%composer, %changed or 0b0001)
}
}
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C<A()>:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ A(%composer, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
"""
)
@@ -2382,22 +2385,7 @@
fun Test(%composer: Composer?, %changed: Int) {
%composer.startRestartGroup(<>, "C(Test)<Wrap>:Test.kt")
if (%changed !== 0 || !%composer.skipping) {
- Wrap(composableLambda(%composer, <>, true, "C<effect>:Test.kt") { %composer: Composer?, %changed: Int ->
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- %composer.startReplaceableGroup(<>, "*<effect>")
- repeat(number) { it: Int ->
- effects[it] = effect({
- 0
- }, %composer, 0)
- }
- %composer.endReplaceableGroup()
- outside = effect({
- "0"
- }, %composer, 0)
- } else {
- %composer.skipToGroupEnd()
- }
- }, %composer, 0b0110)
+ Wrap(ComposableSingletons%TestKt.lambda-1, %composer, 0)
} else {
%composer.skipToGroupEnd()
}
@@ -2405,6 +2393,24 @@
Test(%composer, %changed or 0b0001)
}
}
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C<effect>:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ %composer.startReplaceableGroup(<>, "*<effect>")
+ repeat(number) { it: Int ->
+ effects[it] = effect({
+ 0
+ }, %composer, 0)
+ }
+ %composer.endReplaceableGroup()
+ outside = effect({
+ "0"
+ }, %composer, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
""",
"""
import androidx.compose.runtime.Composable
@@ -3158,27 +3164,7 @@
fun Test(%composer: Composer?, %changed: Int) {
%composer.startRestartGroup(<>, "C(Test)<W>:Test.kt")
if (%changed !== 0 || !%composer.skipping) {
- W(composableLambda(%composer, <>, true, "C<IW>:Test.kt") { %composer: Composer?, %changed: Int ->
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- IW({ %composer: Composer?, %changed: Int ->
- %composer.startReplaceableGroup(<>, "C<T(2)>,<T(4)>:Test.kt")
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- T(2, %composer, 0b0110)
- %composer.startReplaceableGroup(<>, "*<T(3)>")
- repeat(3) { it: Int ->
- T(3, %composer, 0b0110)
- }
- %composer.endReplaceableGroup()
- T(4, %composer, 0b0110)
- } else {
- %composer.skipToGroupEnd()
- }
- %composer.endReplaceableGroup()
- }, %composer, 0)
- } else {
- %composer.skipToGroupEnd()
- }
- }, %composer, 0b0110)
+ W(ComposableSingletons%TestKt.lambda-1, %composer, 0)
} else {
%composer.skipToGroupEnd()
}
@@ -3186,6 +3172,29 @@
Test(%composer, %changed or 0b0001)
}
}
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C<IW>:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ IW({ %composer: Composer?, %changed: Int ->
+ %composer.startReplaceableGroup(<>, "C<T(2)>,<T(4)>:Test.kt")
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ T(2, %composer, 0b0110)
+ %composer.startReplaceableGroup(<>, "*<T(3)>")
+ repeat(3) { it: Int ->
+ T(3, %composer, 0b0110)
+ }
+ %composer.endReplaceableGroup()
+ T(4, %composer, 0b0110)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endReplaceableGroup()
+ }, %composer, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
"""
)
}
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTestsNoSource.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTestsNoSource.kt
index 4ec08fe..31c193f 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTestsNoSource.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/ControlFlowTransformTestsNoSource.kt
@@ -88,13 +88,7 @@
fun Test(%composer: Composer?, %changed: Int) {
%composer.startRestartGroup(<>, "C(Test)")
if (%changed !== 0 || !%composer.skipping) {
- W(composableLambda(%composer, <>, true, null) { %composer: Composer?, %changed: Int ->
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- A(%composer, 0)
- } else {
- %composer.skipToGroupEnd()
- }
- }, %composer, 0b0110)
+ W(ComposableSingletons%TestKt.lambda-1, %composer, 0)
} else {
%composer.skipToGroupEnd()
}
@@ -102,6 +96,15 @@
Test(%composer, %changed or 0b0001)
}
}
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ A(%composer, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
"""
)
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/FunctionBodySkippingTransformTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/FunctionBodySkippingTransformTests.kt
index fda6d65..8dcd32f0 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/FunctionBodySkippingTransformTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/FunctionBodySkippingTransformTests.kt
@@ -693,22 +693,24 @@
} else if (%changed and 0b1110 === 0) {
%dirty = %dirty or if (%composer.changed(modifier)) 0b0100 else 0b0010
}
- if (%default and 0b0010 !== 0) {
- %dirty = %dirty or 0b00110000
- } else if (%changed and 0b01110000 === 0) {
- %dirty = %dirty or if (%composer.changed(content)) 0b00100000 else 0b00010000
+ if (%changed and 0b01110000 === 0) {
+ %dirty = %dirty or if (%default and 0b0010 === 0 && %composer.changed(content)) 0b00100000 else 0b00010000
}
if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
- if (%default and 0b0001 !== 0) {
- modifier = Companion
- }
- if (%default and 0b0010 !== 0) {
- content = composableLambda(%composer, <>, true, "C:Test.kt") { %composer: Composer?, %changed: Int ->
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- Unit
- } else {
- %composer.skipToGroupEnd()
- }
+ if (%changed and 0b0001 === 0 || %composer.defaultsInvalid) {
+ %composer.startDefaults()
+ if (%default and 0b0001 !== 0) {
+ modifier = Companion
+ }
+ if (%default and 0b0010 !== 0) {
+ content = ComposableSingletons%TestKt.lambda-1
+ %dirty = %dirty and 0b01110000.inv()
+ }
+ %composer.endDefaults()
+ } else {
+ %composer.skipCurrentGroup()
+ if (%default and 0b0010 !== 0) {
+ %dirty = %dirty and 0b01110000.inv()
}
}
println()
@@ -719,6 +721,15 @@
SimpleBox(modifier, content, %composer, %changed or 0b0001, %default)
}
}
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
"""
)
@@ -738,19 +749,22 @@
}
""",
"""
- val foo: Function4<Int, Foo, Composer, Int, Unit> = composableLambdaInstance(<>, true) { x: Int, y: Foo, %composer: Composer?, %changed: Int ->
- val %dirty = %changed
- if (%changed and 0b1110 === 0) {
- %dirty = %dirty or if (%composer.changed(x)) 0b0100 else 0b0010
- }
- if (%changed and 0b01110000 === 0) {
- %dirty = %dirty or if (%composer.changed(y)) 0b00100000 else 0b00010000
- }
- if (%dirty and 0b001011011011 xor 0b10010010 !== 0 || !%composer.skipping) {
- A(x, %composer, 0b1110 and %dirty)
- B(y, %composer, 0b1110 and %dirty shr 0b0011)
- } else {
- %composer.skipToGroupEnd()
+ val foo: Function4<Int, Foo, Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-1
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function4<Int, Foo, Composer, Int, Unit> = composableLambdaInstance(<>, false, "C<A(x)>,<B(y)>:") { x: Int, y: Foo, %composer: Composer?, %changed: Int ->
+ val %dirty = %changed
+ if (%changed and 0b1110 === 0) {
+ %dirty = %dirty or if (%composer.changed(x)) 0b0100 else 0b0010
+ }
+ if (%changed and 0b01110000 === 0) {
+ %dirty = %dirty or if (%composer.changed(y)) 0b00100000 else 0b00010000
+ }
+ if (%dirty and 0b001011011011 xor 0b10010010 !== 0 || !%composer.skipping) {
+ A(x, %composer, 0b1110 and %dirty)
+ B(y, %composer, 0b1110 and %dirty shr 0b0011)
+ } else {
+ %composer.skipToGroupEnd()
+ }
}
}
"""
@@ -770,9 +784,12 @@
}
""",
"""
- val foo: Function4<Int, Foo, Composer, Int, Unit> = composableLambdaInstance(<>, true) { x: Int, y: Foo, %composer: Composer?, %changed: Int ->
- A(x, %composer, 0b1110 and %changed)
- B(y, %composer, 0b1000)
+ val foo: Function4<Int, Foo, Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-1
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function4<Int, Foo, Composer, Int, Unit> = composableLambdaInstance(<>, false, "C<A(x)>,<B(y)>:") { x: Int, y: Foo, %composer: Composer?, %changed: Int ->
+ A(x, %composer, 0b1110 and %changed)
+ B(y, %composer, 0b1000)
+ }
}
"""
)
@@ -811,13 +828,7 @@
fun Example(%composer: Composer?, %changed: Int) {
%composer.startRestartGroup(<>, "C(Example)<SomeTh...>:Test.kt")
if (%changed !== 0 || !%composer.skipping) {
- SomeThing(composableLambda(%composer, <>, true, "C:Test.kt") { %composer: Composer?, %changed: Int ->
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- val id = object
- } else {
- %composer.skipToGroupEnd()
- }
- }, %composer, 0b0110)
+ SomeThing(ComposableSingletons%TestKt.lambda-1, %composer, 0)
} else {
%composer.skipToGroupEnd()
}
@@ -825,6 +836,15 @@
Example(%composer, %changed or 0b0001)
}
}
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ val id = object
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
"""
)
@@ -1156,15 +1176,18 @@
}
""",
"""
- val test: Function3<Int, Composer, Int, Unit> = composableLambdaInstance(<>, true) { x: Int, %composer: Composer?, %changed: Int ->
- val %dirty = %changed
- if (%changed and 0b1110 === 0) {
- %dirty = %dirty or if (%composer.changed(x)) 0b0100 else 0b0010
- }
- if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
- A(x, 0, %composer, 0b1110 and %dirty, 0b0010)
- } else {
- %composer.skipToGroupEnd()
+ val test: Function3<Int, Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-1
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function3<Int, Composer, Int, Unit> = composableLambdaInstance(<>, false, "C<A(x)>:") { x: Int, %composer: Composer?, %changed: Int ->
+ val %dirty = %changed
+ if (%changed and 0b1110 === 0) {
+ %dirty = %dirty or if (%composer.changed(x)) 0b0100 else 0b0010
+ }
+ if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
+ A(x, 0, %composer, 0b1110 and %dirty, 0b0010)
+ } else {
+ %composer.skipToGroupEnd()
+ }
}
}
"""
@@ -1492,13 +1515,7 @@
%composer.startRestartGroup(<>, "C(A)<D>,<C({})>,<C(stab...>,<C(16.d...>,<C(Dp(1...>,<C(16.d...>,<C(norm...>,<C(Int....>,<C(stab...>,<C(Modi...>,<C(Foo....>,<C(cons...>,<C(123)>,<C(123>,<C(x)>,<C(x>:Test.kt")
if (%changed !== 0 || !%composer.skipping) {
val x = 123
- D(composableLambda(%composer, <>, true, "C:Test.kt") { %composer: Composer?, %changed: Int ->
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- Unit
- } else {
- %composer.skipToGroupEnd()
- }
- }, %composer, 0b0110)
+ D(ComposableSingletons%TestKt.lambda-1, %composer, 0)
C({
}, %composer, 0)
C(stableFun(123), %composer, 0b0110)
@@ -1535,6 +1552,15 @@
B(%composer, %changed or 0b0001)
}
}
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
"""
)
@@ -1553,13 +1579,7 @@
fun Example(%composer: Composer?, %changed: Int) {
%composer.startRestartGroup(<>, "C(Example)<D>:Test.kt")
if (%changed !== 0 || !%composer.skipping) {
- D(composableLambda(%composer, <>, true, "C:Test.kt") { %composer: Composer?, %changed: Int ->
- if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
- Unit
- } else {
- %composer.skipToGroupEnd()
- }
- }, %composer, 0b0110)
+ D(ComposableSingletons%TestKt.lambda-1, %composer, 0)
} else {
%composer.skipToGroupEnd()
}
@@ -1567,7 +1587,15 @@
Example(%composer, %changed or 0b0001)
}
}
-
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
"""
)
@@ -1895,37 +1923,43 @@
}
""",
"""
- val unstableUnused: @[ExtensionFunctionType] Function3<Foo, Composer, Int, Unit> = composableLambdaInstance(<>, true) { %composer: Composer?, %changed: Int ->
- val %dirty = %changed
- %dirty = %dirty or 0b0110
- if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
- Unit
- } else {
- %composer.skipToGroupEnd()
+ val unstableUnused: @[ExtensionFunctionType] Function3<Foo, Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-1
+ val unstableUsed: @[ExtensionFunctionType] Function3<Foo, Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-2
+ val stableUnused: @[ExtensionFunctionType] Function3<StableFoo, Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-3
+ val stableUsed: @[ExtensionFunctionType] Function3<StableFoo, Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-4
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: @[ExtensionFunctionType] Function3<Foo, Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:") { %composer: Composer?, %changed: Int ->
+ val %dirty = %changed
+ %dirty = %dirty or 0b0110
+ if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
}
- }
- val unstableUsed: @[ExtensionFunctionType] Function3<Foo, Composer, Int, Unit> = composableLambdaInstance(<>, true) { %composer: Composer?, %changed: Int ->
- val %dirty = %changed
- print(x)
- }
- val stableUnused: @[ExtensionFunctionType] Function3<StableFoo, Composer, Int, Unit> = composableLambdaInstance(<>, true) { %composer: Composer?, %changed: Int ->
- val %dirty = %changed
- %dirty = %dirty or 0b0110
- if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
- Unit
- } else {
- %composer.skipToGroupEnd()
- }
- }
- val stableUsed: @[ExtensionFunctionType] Function3<StableFoo, Composer, Int, Unit> = composableLambdaInstance(<>, true) { %composer: Composer?, %changed: Int ->
- val %dirty = %changed
- if (%changed and 0b1110 === 0) {
- %dirty = %dirty or if (%composer.changed(<this>)) 0b0100 else 0b0010
- }
- if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
+ val lambda-2: @[ExtensionFunctionType] Function3<Foo, Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:") { %composer: Composer?, %changed: Int ->
+ val %dirty = %changed
print(x)
- } else {
- %composer.skipToGroupEnd()
+ }
+ val lambda-3: @[ExtensionFunctionType] Function3<StableFoo, Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:") { %composer: Composer?, %changed: Int ->
+ val %dirty = %changed
+ %dirty = %dirty or 0b0110
+ if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ val lambda-4: @[ExtensionFunctionType] Function3<StableFoo, Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:") { %composer: Composer?, %changed: Int ->
+ val %dirty = %changed
+ if (%changed and 0b1110 === 0) {
+ %dirty = %dirty or if (%composer.changed(<this>)) 0b0100 else 0b0010
+ }
+ if (%dirty and 0b01011011 xor 0b00010010 !== 0 || !%composer.skipping) {
+ print(x)
+ } else {
+ %composer.skipToGroupEnd()
+ }
}
}
"""
@@ -2649,13 +2683,12 @@
"""
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
- import androidx.compose.runtime.emptyContent
@Composable
fun Box2(
modifier: Modifier = Modifier,
paddingStart: Dp = Dp.Unspecified,
- content: @Composable () -> Unit = emptyContent()
+ content: @Composable () -> Unit = {}
) {
}
@@ -2676,10 +2709,8 @@
if (%changed and 0b01110000 === 0) {
%dirty = %dirty or if (%default and 0b0010 === 0 && %composer.changed(paddingStart.value)) 0b00100000 else 0b00010000
}
- if (%default and 0b0100 !== 0) {
- %dirty = %dirty or 0b000110000000
- } else if (%changed and 0b001110000000 === 0) {
- %dirty = %dirty or if (%composer.changed(content)) 0b000100000000 else 0b10000000
+ if (%changed and 0b001110000000 === 0) {
+ %dirty = %dirty or if (%default and 0b0100 === 0 && %composer.changed(content)) 0b000100000000 else 0b10000000
}
if (%dirty and 0b001011011011 xor 0b10010010 !== 0 || !%composer.skipping) {
if (%changed and 0b0001 === 0 || %composer.defaultsInvalid) {
@@ -2692,7 +2723,8 @@
%dirty = %dirty and 0b01110000.inv()
}
if (%default and 0b0100 !== 0) {
- content = emptyContent()
+ content = ComposableSingletons%TestKt.lambda-1
+ %dirty = %dirty and 0b001110000000.inv()
}
%composer.endDefaults()
} else {
@@ -2700,6 +2732,9 @@
if (%default and 0b0010 !== 0) {
%dirty = %dirty and 0b01110000.inv()
}
+ if (%default and 0b0100 !== 0) {
+ %dirty = %dirty and 0b001110000000.inv()
+ }
}
} else {
%composer.skipToGroupEnd()
@@ -2708,6 +2743,15 @@
Box2(modifier, paddingStart, content, %composer, %changed or 0b0001, %default)
}
}
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
"""
)
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/LambdaMemoizationTransformTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/LambdaMemoizationTransformTests.kt
index 9b11630..1e4199a 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/LambdaMemoizationTransformTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/LambdaMemoizationTransformTests.kt
@@ -20,6 +20,273 @@
class LambdaMemoizationTransformTests : ComposeIrTransformTest() {
+ @Test
+ fun testCapturedThisFromFieldInitializer(): Unit = verifyComposeIrTransform(
+ """
+ import androidx.compose.runtime.Composable
+
+ class A {
+ val b = ""
+ val c = @Composable {
+ print(b)
+ }
+ }
+ """,
+ """
+ @StabilityInferred(parameters = 0)
+ class A {
+ val b: String = ""
+ val c: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, true, "") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ print(b)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ static val %stable: Int = 0
+ }
+ """,
+ """
+ """
+ )
+
+ @Test
+ fun testLocalInALocal(): Unit = verifyComposeIrTransform(
+ """
+ import androidx.compose.runtime.Composable
+
+ @Composable fun Example() {
+ @Composable fun A() { }
+ @Composable fun B(content: @Composable () -> Unit) { }
+ @Composable fun C() {
+ B { A() }
+ }
+ }
+ """,
+ """
+ @Composable
+ fun Example(%composer: Composer?, %changed: Int) {
+ %composer.startRestartGroup(<>, "C(Example):Test.kt")
+ if (%changed !== 0 || !%composer.skipping) {
+ @Composable
+ fun A(%composer: Composer?, %changed: Int) {
+ %composer.startRestartGroup(<>, "C(A):Test.kt")
+ if (%changed !== 0 || !%composer.skipping) {
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
+ A(%composer, %changed or 0b0001)
+ }
+ }
+ @Composable
+ fun B(content: Function2<Composer, Int, Unit>, %composer: Composer?, %changed: Int) {
+ %composer.startRestartGroup(<>, "C(B):Test.kt")
+ val %dirty = %changed
+ if (%changed and 0b1110 === 0) {
+ %dirty = %dirty or if (%composer.changed(content)) 0b0100 else 0b0010
+ }
+ if (%dirty and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
+ B(content, %composer, %changed or 0b0001)
+ }
+ }
+ @Composable
+ fun C(%composer: Composer?, %changed: Int) {
+ %composer.startRestartGroup(<>, "C(C)<B>:Test.kt")
+ if (%changed !== 0 || !%composer.skipping) {
+ B(composableLambda(%composer, <>, false, "C<A()>:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ A(%composer, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }, %composer, 0b0110)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
+ C(%composer, %changed or 0b0001)
+ }
+ }
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
+ Example(%composer, %changed or 0b0001)
+ }
+ }
+ """,
+ """
+ """
+ )
+
+ @Test
+ fun testStateDelegateCapture(): Unit = verifyComposeIrTransform(
+ """
+ import androidx.compose.runtime.Composable
+ import androidx.compose.runtime.mutableStateOf
+ import androidx.compose.runtime.getValue
+
+ @Composable fun A() {
+ val x by mutableStateOf(123)
+ B {
+ print(x)
+ }
+ }
+ """,
+ """
+ @Composable
+ fun A(%composer: Composer?, %changed: Int) {
+ %composer.startRestartGroup(<>, "C(A)<B>:Test.kt")
+ if (%changed !== 0 || !%composer.skipping) {
+ <<LOCALDELPROP>>
+ B(composableLambda(%composer, <>, true, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ print(<get-x>())
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }, %composer, 0b0110)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
+ A(%composer, %changed or 0b0001)
+ }
+ }
+ """,
+ """
+ import androidx.compose.runtime.Composable
+
+ @Composable fun B(content: @Composable () -> Unit) {}
+ """
+ )
+
+ @Test
+ fun testTopLevelComposableLambdaProperties(): Unit = verifyComposeIrTransform(
+ """
+ import androidx.compose.runtime.Composable
+
+ val foo = @Composable {}
+ val bar: @Composable () -> Unit = {}
+ """,
+ """
+ val foo: Function2<Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-1
+ val bar: Function2<Composer, Int, Unit> = ComposableSingletons%TestKt.lambda-2
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ val lambda-2: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
+ """,
+ """
+ """
+ )
+
+ @Test
+ fun testLocalVariableComposableLambdas(): Unit = verifyComposeIrTransform(
+ """
+ import androidx.compose.runtime.Composable
+
+ @Composable fun A() {
+ val foo = @Composable {}
+ val bar: @Composable () -> Unit = {}
+ B(foo)
+ B(bar)
+ }
+ """,
+ """
+ @Composable
+ fun A(%composer: Composer?, %changed: Int) {
+ %composer.startRestartGroup(<>, "C(A)<B(foo)>,<B(bar)>:Test.kt")
+ if (%changed !== 0 || !%composer.skipping) {
+ val foo = ComposableSingletons%TestKt.lambda-1
+ val bar = ComposableSingletons%TestKt.lambda-2
+ B(foo, %composer, 0)
+ B(bar, %composer, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
+ A(%composer, %changed or 0b0001)
+ }
+ }
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ val lambda-2: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
+ """,
+ """
+ import androidx.compose.runtime.Composable
+ @Composable fun B(content: @Composable () -> Unit) {}
+ """
+ )
+
+ @Test
+ fun testParameterComposableLambdas(): Unit = verifyComposeIrTransform(
+ """
+ import androidx.compose.runtime.Composable
+
+ @Composable fun A() {
+ B {}
+ }
+ """,
+ """
+ @Composable
+ fun A(%composer: Composer?, %changed: Int) {
+ %composer.startRestartGroup(<>, "C(A)<B>:Test.kt")
+ if (%changed !== 0 || !%composer.skipping) {
+ B(ComposableSingletons%TestKt.lambda-1, %composer, 0)
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
+ A(%composer, %changed or 0b0001)
+ }
+ }
+ internal class ComposableSingletons%TestKt {
+ val lambda-1: Function2<Composer, Int, Unit> = composableLambdaInstance(<>, false, "C:Test.kt") { %composer: Composer?, %changed: Int ->
+ if (%changed and 0b1011 xor 0b0010 !== 0 || !%composer.skipping) {
+ Unit
+ } else {
+ %composer.skipToGroupEnd()
+ }
+ }
+ }
+ """,
+ """
+ import androidx.compose.runtime.Composable
+ @Composable fun B(content: @Composable () -> Unit) {}
+ """
+ )
+
@Test // regression of b/162575428
fun testComposableInAFunctionParameter(): Unit = verifyComposeIrTransform(
"""
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/TryCatchComposableCheckerTests.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/TryCatchComposableCheckerTests.kt
index 6c63e91..93fbd5e 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/TryCatchComposableCheckerTests.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/analysis/TryCatchComposableCheckerTests.kt
@@ -98,7 +98,7 @@
doTest(
"""
import androidx.compose.runtime.*
- var globalContent = emptyContent()
+ var globalContent = @Composable {}
fun setContent(content: @Composable () -> Unit) {
globalContent = content
}
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposeWritableSlices.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposeWritableSlices.kt
index 4d9386f..9fe3c46 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposeWritableSlices.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/analysis/ComposeWritableSlices.kt
@@ -19,4 +19,8 @@
BasicWritableSlice(RewritePolicy.DO_NOTHING)
val IS_SYNTHETIC_COMPOSABLE_CALL: WritableSlice<IrFunctionAccessExpression, Boolean> =
BasicWritableSlice(RewritePolicy.DO_NOTHING)
+ val IS_COMPOSABLE_SINGLETON: WritableSlice<IrAttributeContainer, Boolean> =
+ BasicWritableSlice(RewritePolicy.DO_NOTHING)
+ val IS_COMPOSABLE_SINGLETON_CLASS: WritableSlice<IrAttributeContainer, Boolean> =
+ BasicWritableSlice(RewritePolicy.DO_NOTHING)
}
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/AbstractComposeLowering.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/AbstractComposeLowering.kt
index d852691..16f0e5a 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/AbstractComposeLowering.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/AbstractComposeLowering.kt
@@ -331,6 +331,14 @@
return context.irTrace[ComposeWritableSlices.IS_SYNTHETIC_COMPOSABLE_CALL, this] == true
}
+ fun IrCall.isComposableSingletonGetter(): Boolean {
+ return context.irTrace[ComposeWritableSlices.IS_COMPOSABLE_SINGLETON, this] == true
+ }
+
+ fun IrClass.isComposableSingletonClass(): Boolean {
+ return context.irTrace[ComposeWritableSlices.IS_COMPOSABLE_SINGLETON_CLASS, this] == true
+ }
+
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun IrFunction.isInlinedLambda(): Boolean {
descriptor.findPsi()?.let { psi ->
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableFunctionBodyTransformer.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableFunctionBodyTransformer.kt
index ca17dd2..07950c0 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableFunctionBodyTransformer.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableFunctionBodyTransformer.kt
@@ -653,10 +653,14 @@
private val collectSourceInformation = sourceInformationEnabled
- override fun visitClass(declaration: IrClass): IrStatement =
- inScope(Scope.ClassScope(declaration.name)) {
+ override fun visitClass(declaration: IrClass): IrStatement {
+ if (declaration.isComposableSingletonClass()) {
+ return declaration
+ }
+ return inScope(Scope.ClassScope(declaration.name)) {
super.visitDeclaration(declaration)
}
+ }
override fun visitFunction(declaration: IrFunction): IrStatement {
val scope = Scope.FunctionScope(declaration, this)
@@ -2522,6 +2526,23 @@
recordSourceParameter(expression, 3, composableLambdaScope)
return expression
}
+ expression.isComposableSingletonGetter() -> {
+ // This looks like `ComposableSingletonClass.lambda-123`, which is a static/saved
+ // call of composableLambdaInstance. We want to pass
+ // locations on the top level of the lambda as the startRestartGroup is in the
+ // composable lambda wrapper.
+ val getter = expression.symbol.owner
+ val property = getter.correspondingPropertySymbol?.owner
+ val fieldInitializer = property?.backingField?.initializer?.expression
+ val composableLambdaInstanceCall = fieldInitializer as IrCall
+ val composableLambdaScope = withScope(Scope.ComposableLambdaScope()) {
+ property.transformChildrenVoid()
+ }
+ if (collectSourceInformation) {
+ recordSourceParameter(composableLambdaInstanceCall, 2, composableLambdaScope)
+ }
+ return super.visitCall(expression)
+ }
else -> return super.visitCall(expression)
}
}
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerLambdaMemoization.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerLambdaMemoization.kt
index 615237a..5d6c1b2 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerLambdaMemoization.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerLambdaMemoization.kt
@@ -23,28 +23,47 @@
import androidx.compose.compiler.plugins.kotlin.irTrace
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl
+import org.jetbrains.kotlin.backend.common.ir.addChild
+import org.jetbrains.kotlin.backend.common.ir.copyTo
+import org.jetbrains.kotlin.backend.common.ir.createParameterDeclarations
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
import org.jetbrains.kotlin.backend.common.peek
import org.jetbrains.kotlin.backend.common.pop
import org.jetbrains.kotlin.backend.common.push
+import org.jetbrains.kotlin.descriptors.ClassKind
+import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
+import org.jetbrains.kotlin.ir.builders.declarations.addConstructor
+import org.jetbrains.kotlin.ir.builders.declarations.addGetter
+import org.jetbrains.kotlin.ir.builders.declarations.addProperty
+import org.jetbrains.kotlin.ir.builders.declarations.buildClass
+import org.jetbrains.kotlin.ir.builders.declarations.buildField
import org.jetbrains.kotlin.ir.builders.irBlock
+import org.jetbrains.kotlin.ir.builders.irBlockBody
import org.jetbrains.kotlin.ir.builders.irBoolean
import org.jetbrains.kotlin.ir.builders.irCall
+import org.jetbrains.kotlin.ir.builders.irDelegatingConstructorCall
+import org.jetbrains.kotlin.ir.builders.irExprBody
import org.jetbrains.kotlin.ir.builders.irGet
+import org.jetbrains.kotlin.ir.builders.irGetField
import org.jetbrains.kotlin.ir.builders.irInt
import org.jetbrains.kotlin.ir.builders.irNull
import org.jetbrains.kotlin.ir.builders.irReturn
import org.jetbrains.kotlin.ir.builders.irTemporary
+import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
+import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrDeclarationBase
+import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
+import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
import org.jetbrains.kotlin.ir.declarations.IrValueDeclaration
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.declarations.copyAttributes
+import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionExpression
@@ -53,14 +72,20 @@
import org.jetbrains.kotlin.ir.expressions.IrValueAccessExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl
+import org.jetbrains.kotlin.ir.expressions.impl.IrGetObjectValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSymbol
+import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper
import org.jetbrains.kotlin.ir.util.defaultType
+import org.jetbrains.kotlin.ir.util.isLocal
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
+import org.jetbrains.kotlin.ir.util.primaryConstructor
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
+import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
+import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtFunctionLiteral
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
@@ -69,10 +94,16 @@
private class CaptureCollector {
val captures = mutableSetOf<IrValueDeclaration>()
+ val capturedFunctions = mutableSetOf<IrFunction>()
+ val hasCaptures: Boolean get() = captures.isNotEmpty() || capturedFunctions.isNotEmpty()
fun recordCapture(local: IrValueDeclaration) {
captures.add(local)
}
+
+ fun recordCapture(local: IrFunction) {
+ capturedFunctions.add(local)
+ }
}
private abstract class DeclarationContext {
@@ -80,7 +111,9 @@
abstract val symbol: IrSymbol
abstract val functionContext: FunctionContext?
abstract fun declareLocal(local: IrValueDeclaration?)
+ abstract fun recordLocalFunction(local: FunctionContext)
abstract fun recordCapture(local: IrValueDeclaration?)
+ abstract fun recordCapture(local: IrFunction?)
abstract fun pushCollector(collector: CaptureCollector)
abstract fun popCollector(collector: CaptureCollector)
}
@@ -90,7 +123,9 @@
override val functionContext: FunctionContext? get() = null
override val symbol get() = declaration.symbol
override fun declareLocal(local: IrValueDeclaration?) { }
+ override fun recordLocalFunction(local: FunctionContext) { }
override fun recordCapture(local: IrValueDeclaration?) { }
+ override fun recordCapture(local: IrFunction?) { }
override fun pushCollector(collector: CaptureCollector) { }
override fun popCollector(collector: CaptureCollector) { }
}
@@ -102,7 +137,10 @@
override val composable: Boolean get() = functionContext.composable
override val symbol: IrSymbol get() = declaration.symbol
override fun declareLocal(local: IrValueDeclaration?) = functionContext.declareLocal(local)
+ override fun recordLocalFunction(local: FunctionContext) =
+ functionContext.recordLocalFunction(local)
override fun recordCapture(local: IrValueDeclaration?) = functionContext.recordCapture(local)
+ override fun recordCapture(local: IrFunction?) = functionContext.recordCapture(local)
override fun pushCollector(collector: CaptureCollector) =
functionContext.pushCollector(collector)
override fun popCollector(collector: CaptureCollector) =
@@ -117,7 +155,9 @@
override val symbol get() = declaration.symbol
override val functionContext: FunctionContext? get() = this
val locals = mutableSetOf<IrValueDeclaration>()
+ val captures = mutableSetOf<IrValueDeclaration>()
var collectors = mutableListOf<CaptureCollector>()
+ val localFunctionCaptures = mutableMapOf<IrFunction, Set<IrValueDeclaration>>()
init {
declaration.valueParameters.forEach {
@@ -133,12 +173,35 @@
}
}
+ override fun recordLocalFunction(local: FunctionContext) {
+ if (local.captures.isNotEmpty() && local.declaration.isLocal) {
+ localFunctionCaptures[local.declaration] = local.captures
+ }
+ }
+
override fun recordCapture(local: IrValueDeclaration?) {
if (local != null && collectors.isNotEmpty() && locals.contains(local)) {
for (collector in collectors) {
collector.recordCapture(local)
}
}
+ if (local != null && declaration.isLocal && !locals.contains(local)) {
+ captures.add(local)
+ }
+ }
+
+ override fun recordCapture(local: IrFunction?) {
+ if (local != null) {
+ val captures = localFunctionCaptures[local]
+ for (collector in collectors) {
+ collector.recordCapture(local)
+ if (captures != null) {
+ for (capture in captures) {
+ collector.recordCapture(capture)
+ }
+ }
+ }
+ }
}
override fun pushCollector(collector: CaptureCollector) {
@@ -151,6 +214,31 @@
}
}
+private class ClassContext(val declaration: IrClass) : DeclarationContext() {
+ override val composable: Boolean = false
+ override val symbol get() = declaration.symbol
+ override val functionContext: FunctionContext? = null
+ val thisParam: IrValueDeclaration? = declaration.thisReceiver!!
+ var collectors = mutableListOf<CaptureCollector>()
+ override fun declareLocal(local: IrValueDeclaration?) { }
+ override fun recordLocalFunction(local: FunctionContext) { }
+ override fun recordCapture(local: IrValueDeclaration?) {
+ if (local != null && collectors.isNotEmpty() && local == thisParam) {
+ for (collector in collectors) {
+ collector.recordCapture(local)
+ }
+ }
+ }
+ override fun recordCapture(local: IrFunction?) { }
+ override fun pushCollector(collector: CaptureCollector) {
+ collectors.add(collector)
+ }
+ override fun popCollector(collector: CaptureCollector) {
+ require(collectors.lastOrNull() == collector)
+ collectors.removeAt(collectors.size - 1)
+ }
+}
+
const val COMPOSABLE_LAMBDA = "composableLambda"
const val COMPOSABLE_LAMBDA_N = "composableLambdaN"
const val COMPOSABLE_LAMBDA_INSTANCE = "composableLambdaInstance"
@@ -170,6 +258,65 @@
private val currentFunctionContext: FunctionContext? get() =
declarationContextStack.peek()?.functionContext
+ private var composableSingletonsClass: IrClass? = null
+ private var currentFile: IrFile? = null
+
+ private fun getOrCreateComposableSingletonsClass(): IrClass {
+ if (composableSingletonsClass != null) return composableSingletonsClass!!
+ val declaration = currentFile!!
+ val filePath = declaration.fileEntry.name
+ val fileName = filePath.split('/').last()
+ val current = context.irFactory.buildClass {
+ kind = ClassKind.OBJECT
+ visibility = DescriptorVisibilities.INTERNAL
+ val shortName = PackagePartClassUtils.getFilePartShortName(fileName)
+ // the name of the LiveLiterals class is per-file, so we use the same name that
+ // the kotlin file class lowering produces, prefixed with `LiveLiterals$`.
+ name = Name.identifier("ComposableSingletons${"$"}$shortName")
+ }.also {
+ it.createParameterDeclarations()
+
+ // store the full file path to the file that this class is associated with in an
+ // annotation on the class. This will be used by tooling to associate the keys
+ // inside of this class with actual PSI in the editor.
+ it.addConstructor {
+ isPrimary = true
+ }.also { ctor ->
+ ctor.body = DeclarationIrBuilder(context, it.symbol).irBlockBody {
+ +irDelegatingConstructorCall(
+ context
+ .irBuiltIns
+ .anyClass
+ .owner
+ .primaryConstructor!!
+ )
+ }
+ }
+ }.markAsComposableSingletonClass()
+ composableSingletonsClass = current
+ return current
+ }
+
+ override fun visitFile(declaration: IrFile): IrFile {
+ val prevFile = currentFile
+ val prevClass = composableSingletonsClass
+ try {
+ currentFile = declaration
+ composableSingletonsClass = null
+ val file = super.visitFile(declaration)
+ // if there were no constants found in the entire file, then we don't need to
+ // create this class at all
+ val resultingClass = composableSingletonsClass
+ if (resultingClass != null && resultingClass.declarations.isNotEmpty()) {
+ file.addChild(resultingClass)
+ }
+ return file
+ } finally {
+ currentFile = prevFile
+ composableSingletonsClass = prevClass
+ }
+ }
+
override fun lower(module: IrModuleFragment) = module.transformChildrenVoid(this)
override fun visitDeclaration(declaration: IrDeclarationBase): IrStatement {
@@ -214,9 +361,21 @@
// TODO(b/150390108): Consider allowing remember in effects
descriptor.returnType.let { it != null && it.isUnit() }
- declarationContextStack.push(FunctionContext(declaration, composable, canRemember))
+ val context = FunctionContext(declaration, composable, canRemember)
+ declarationContextStack.push(context)
val result = super.visitFunction(declaration)
declarationContextStack.pop()
+ if (declaration.isLocal) {
+ declarationContextStack.peek()?.recordLocalFunction(context)
+ }
+ return result
+ }
+
+ override fun visitClass(declaration: IrClass): IrStatement {
+ val context = ClassContext(declaration)
+ declarationContextStack.push(context)
+ val result = super.visitClass(declaration)
+ declarationContextStack.pop()
return result
}
@@ -226,7 +385,9 @@
}
override fun visitValueAccess(expression: IrValueAccessExpression): IrExpression {
- declarationContextStack.forEach { it.recordCapture(expression.symbol.owner) }
+ declarationContextStack.forEach {
+ it.recordCapture(expression.symbol.owner)
+ }
return super.visitValueAccess(expression)
}
@@ -334,12 +495,25 @@
)
}
+ override fun visitCall(expression: IrCall): IrExpression {
+ val fn = expression.symbol.owner
+ if (fn.isLocal) {
+ declarationContextStack.forEach {
+ it.recordCapture(fn)
+ }
+ }
+ return super.visitCall(expression)
+ }
+
@ObsoleteDescriptorBasedAPI
private fun visitComposableFunctionExpression(
expression: IrFunctionExpression,
declarationContext: DeclarationContext
): IrExpression {
+ val collector = CaptureCollector()
+ startCollector(collector)
val result = super.visitFunctionExpression(expression)
+ stopCollector(collector)
// If the ancestor converted this then return
val functionExpression = result as? IrFunctionExpression ?: return result
@@ -352,7 +526,61 @@
return functionExpression
}
- return wrapFunctionExpression(declarationContext, functionExpression)
+ val wrapped = wrapFunctionExpression(declarationContext, functionExpression, collector)
+
+ if (!collector.hasCaptures) {
+ return irGetComposableSingleton(
+ lambdaExpression = wrapped,
+ lambdaType = expression.type
+ )
+ } else {
+ return wrapped
+ }
+ }
+
+ private fun irGetComposableSingleton(
+ lambdaExpression: IrExpression,
+ lambdaType: IrType
+ ): IrExpression {
+ val clazz = getOrCreateComposableSingletonsClass()
+ val lambdaName = "lambda-${clazz.declarations.size}"
+ val lambdaProp = clazz.addProperty {
+ name = Name.identifier(lambdaName)
+ visibility = DescriptorVisibilities.INTERNAL
+ }.also { p ->
+ p.backingField = context.irFactory.buildField {
+ name = Name.identifier(lambdaName)
+ type = lambdaType
+ visibility = DescriptorVisibilities.INTERNAL
+ isStatic = true
+ }.also { f ->
+ f.correspondingPropertySymbol = p.symbol
+ f.parent = clazz
+ f.initializer = DeclarationIrBuilder(context, clazz.symbol)
+ .irExprBody(lambdaExpression)
+ }
+ p.addGetter {
+ returnType = lambdaType
+ visibility = DescriptorVisibilities.INTERNAL
+ origin = IrDeclarationOrigin.DEFAULT_PROPERTY_ACCESSOR
+ }.also { fn ->
+ val thisParam = clazz.thisReceiver!!.copyTo(fn)
+ fn.parent = clazz
+ fn.dispatchReceiverParameter = thisParam
+ fn.body = DeclarationIrBuilder(context, fn.symbol).irBlockBody {
+ +irReturn(irGetField(irGet(thisParam), p.backingField!!))
+ }
+ }
+ }
+ return irCall(
+ lambdaProp.getter!!.symbol,
+ dispatchReceiver = IrGetObjectValueImpl(
+ startOffset = UNDEFINED_OFFSET,
+ endOffset = UNDEFINED_OFFSET,
+ type = clazz.defaultType,
+ symbol = clazz.symbol
+ )
+ ).markAsComposableSingleton()
}
@ObsoleteDescriptorBasedAPI
@@ -380,13 +608,15 @@
@ObsoleteDescriptorBasedAPI
private fun wrapFunctionExpression(
declarationContext: DeclarationContext,
- expression: IrFunctionExpression
+ expression: IrFunctionExpression,
+ collector: CaptureCollector
): IrExpression {
val function = expression.function
val argumentCount = function.descriptor.valueParameters.size
val useComposableLambdaN = argumentCount > MAX_RESTART_ARGUMENT_COUNT
+ val useComposableFactory = collector.hasCaptures && declarationContext.composable
val restartFunctionFactory =
- if (declarationContext.composable)
+ if (useComposableFactory)
if (useComposableLambdaN)
COMPOSABLE_LAMBDA_N
else COMPOSABLE_LAMBDA
@@ -406,8 +636,8 @@
return irBuilder.irCall(restartFactorySymbol).apply {
var index = 0
- // first parameter is the composer parameter if we are in a composable context
- if (declarationContext.composable) {
+ // first parameter is the composer parameter if we are using the composable factory
+ if (useComposableFactory) {
putValueArgument(
index++,
irCurrentComposer()
@@ -424,12 +654,13 @@
)
// tracked parameter
- putValueArgument(index++, irBuilder.irBoolean(expression.isTracked()))
+ // If the lambda has no captures, then kotlin will turn it into a singleton instance,
+ // which means that it will never change, thus does not need to be tracked.
+ val shouldBeTracked = expression.isTracked() && collector.captures.isNotEmpty()
+ putValueArgument(index++, irBuilder.irBoolean(shouldBeTracked))
- if (declarationContext.composable) {
- // sourceInformation parameter
- putValueArgument(index++, irBuilder.irNull())
- }
+ // sourceInformation parameter
+ putValueArgument(index++, irBuilder.irNull())
// ComposableLambdaN requires the arity
if (useComposableLambdaN) {
@@ -551,6 +782,28 @@
return this
}
+ private fun <T : IrAttributeContainer> T.markAsComposableSingleton(): T {
+ // Mark it so the ComposableCallTransformer can insert the correct source information
+ // around this call
+ context.irTrace.record(
+ ComposeWritableSlices.IS_COMPOSABLE_SINGLETON,
+ this,
+ true
+ )
+ return this
+ }
+
+ private fun <T : IrAttributeContainer> T.markAsComposableSingletonClass(): T {
+ // Mark it so the ComposableCallTransformer can insert the correct source information
+ // around this call
+ context.irTrace.record(
+ ComposeWritableSlices.IS_COMPOSABLE_SINGLETON_CLASS,
+ this,
+ true
+ )
+ return this
+ }
+
@OptIn(ObsoleteDescriptorBasedAPI::class)
private fun IrFunctionExpression.isInlineArgument(): Boolean {
function.descriptor.findPsi()?.let { psi ->
diff --git a/compose/desktop/desktop/src/jvmMain/kotlin/androidx/compose/ui/window/WindowDraggableArea.kt b/compose/desktop/desktop/src/jvmMain/kotlin/androidx/compose/ui/window/WindowDraggableArea.kt
index 60b07ce..a058795 100644
--- a/compose/desktop/desktop/src/jvmMain/kotlin/androidx/compose/ui/window/WindowDraggableArea.kt
+++ b/compose/desktop/desktop/src/jvmMain/kotlin/androidx/compose/ui/window/WindowDraggableArea.kt
@@ -19,7 +19,6 @@
import androidx.compose.desktop.AppManager
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
@@ -30,7 +29,7 @@
@Composable
fun WindowDraggableArea(
modifier: Modifier = Modifier,
- content: @Composable() () -> Unit = emptyContent()
+ content: @Composable() () -> Unit = {}
) {
Box(
modifier = modifier.dragGestureFilter(
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/IntrinsicTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/IntrinsicTest.kt
index 4b170d8..0584869 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/IntrinsicTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/IntrinsicTest.kt
@@ -17,7 +17,6 @@
package androidx.compose.foundation.layout
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
@@ -483,7 +482,7 @@
maxIntrinsicHeight: Dp
) {
Layout(
- emptyContent(),
+ {},
minIntrinsicWidthMeasureBlock = { _, _ -> minIntrinsicWidth.toIntPx() },
minIntrinsicHeightMeasureBlock = { _, _ -> minIntrinsicHeight.toIntPx() },
maxIntrinsicWidthMeasureBlock = { _, _ -> maxIntrinsicWidth.toIntPx() },
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
index 392bf97..3326100 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
@@ -19,7 +19,6 @@
import androidx.compose.ui.layout.FirstBaseline
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Providers
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.Alignment
import androidx.compose.ui.layout.HorizontalAlignmentLine
import androidx.compose.ui.layout.Layout
@@ -1342,12 +1341,12 @@
Modifier.weight(1f),
width = sizeDp,
height = sizeDp,
- content = emptyContent()
+ content = {}
)
Container(
width = (sizeDp * 2),
height = (sizeDp * 2),
- content = emptyContent()
+ content = {}
)
}
}
@@ -1476,12 +1475,12 @@
Modifier.weight(1f),
width = sizeDp,
height = sizeDp,
- content = emptyContent()
+ content = {}
)
Container(
width = sizeDp * 2,
height = sizeDp * 2,
- content = emptyContent()
+ content = {}
)
}
}
@@ -1812,12 +1811,12 @@
Modifier.weight(1f),
width = sizeDp,
height = sizeDp,
- content = emptyContent()
+ content = {}
)
Container(
width = (sizeDp * 2),
height = (sizeDp * 2),
- content = emptyContent()
+ content = {}
)
}
}
@@ -1946,12 +1945,12 @@
Modifier.weight(1f),
width = sizeDp,
height = sizeDp,
- content = emptyContent()
+ content = {}
)
Container(
width = sizeDp * 2,
height = sizeDp * 2,
- content = emptyContent()
+ content = {}
)
}
}
@@ -2139,7 +2138,7 @@
assertEquals(Constraints(), constraints)
FixedSizeLayout(0, noWeightChildHeight.toIntPx(), mapOf())
}
- Layout(emptyContent(), Modifier.weight(1f)) { _, constraints ->
+ Layout({}, Modifier.weight(1f)) { _, constraints ->
assertEquals(
columnMinHeight.toIntPx() - noWeightChildHeight.toIntPx() * 2,
constraints.minHeight
@@ -3206,19 +3205,19 @@
testIntrinsics(
@Composable {
Row {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Row(Modifier.fillMaxWidth()) {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3227,12 +3226,12 @@
Container(
Modifier.aspectRatio(2f)
.align(Alignment.Top),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.align(Alignment.CenterVertically),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3240,21 +3239,21 @@
Row {
Container(
Modifier.aspectRatio(2f).alignBy(FirstBaseline),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.alignBy { it.width },
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Start) {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3262,12 +3261,12 @@
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
Container(
Modifier.align(Alignment.CenterVertically).aspectRatio(2f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.align(Alignment.CenterVertically),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3275,40 +3274,40 @@
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) {
Container(
Modifier.align(Alignment.Bottom).aspectRatio(2f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.align(Alignment.Bottom),
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceAround) {
- Container(Modifier.fillMaxHeight().aspectRatio(2f), content = emptyContent())
+ Container(Modifier.fillMaxHeight().aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.fillMaxHeight(),
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceEvenly) {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
}
@@ -3346,17 +3345,17 @@
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
Modifier.weight(3f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(30.toDp(), 40.toDp()),
Modifier.weight(2f),
- content = emptyContent()
+ content = {}
)
- Container(Modifier.aspectRatio(2f).weight(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f).weight(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3365,18 +3364,18 @@
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
Modifier.weight(3f).align(Alignment.Top),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(30.toDp(), 40.toDp()),
Modifier.weight(2f).align(Alignment.CenterVertically),
- content = emptyContent()
+ content = {}
)
- Container(Modifier.aspectRatio(2f).weight(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f).weight(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
Modifier.align(Alignment.Bottom),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3385,17 +3384,17 @@
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
Modifier.weight(3f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(30.toDp(), 40.toDp()),
Modifier.weight(2f),
- content = emptyContent()
+ content = {}
)
- Container(Modifier.aspectRatio(2f).weight(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f).weight(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3404,21 +3403,21 @@
ConstrainedBox(
constraints = DpConstraints.fixed(20.toDp(), 30.toDp()),
modifier = Modifier.weight(3f).align(Alignment.CenterVertically),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
constraints = DpConstraints.fixed(30.toDp(), 40.toDp()),
modifier = Modifier.weight(2f).align(Alignment.CenterVertically),
- content = emptyContent()
+ content = {}
)
Container(
Modifier.aspectRatio(2f).weight(2f).align(Alignment.CenterVertically),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
constraints = DpConstraints.fixed(20.toDp(), 30.toDp()),
modifier = Modifier.align(Alignment.CenterVertically),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3427,21 +3426,21 @@
ConstrainedBox(
constraints = DpConstraints.fixed(20.toDp(), 30.toDp()),
modifier = Modifier.weight(3f).align(Alignment.Bottom),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
constraints = DpConstraints.fixed(30.toDp(), 40.toDp()),
modifier = Modifier.weight(2f).align(Alignment.Bottom),
- content = emptyContent()
+ content = {}
)
Container(
Modifier.aspectRatio(2f).weight(2f).align(Alignment.Bottom),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
constraints = DpConstraints.fixed(20.toDp(), 30.toDp()),
modifier = Modifier.align(Alignment.Bottom),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3450,21 +3449,21 @@
ConstrainedBox(
constraints = DpConstraints.fixed(20.toDp(), 30.toDp()),
modifier = Modifier.weight(3f).fillMaxHeight(),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
constraints = DpConstraints.fixed(30.toDp(), 40.toDp()),
modifier = Modifier.weight(2f).fillMaxHeight(),
- content = emptyContent()
+ content = {}
)
Container(
Modifier.aspectRatio(2f).weight(2f).fillMaxHeight(),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
constraints = DpConstraints.fixed(20.toDp(), 30.toDp()),
modifier = Modifier.fillMaxHeight(),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3473,17 +3472,17 @@
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
Modifier.weight(3f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(30.toDp(), 40.toDp()),
Modifier.weight(2f),
- content = emptyContent()
+ content = {}
)
- Container(Modifier.aspectRatio(2f).weight(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f).weight(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3492,17 +3491,17 @@
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
Modifier.weight(3f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(30.toDp(), 40.toDp()),
Modifier.weight(2f),
- content = emptyContent()
+ content = {}
)
- Container(Modifier.aspectRatio(2f).weight(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f).weight(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(20.toDp(), 30.toDp()),
- content = emptyContent()
+ content = {}
)
}
}
@@ -3559,10 +3558,10 @@
testIntrinsics(
@Composable {
Column {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3570,12 +3569,12 @@
Column {
Container(
Modifier.aspectRatio(2f).align(Alignment.Start),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.align(Alignment.End),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3583,30 +3582,30 @@
Column {
Container(
Modifier.aspectRatio(2f).alignBy { 0 },
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.alignBy(TestVerticalLine),
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Column(Modifier.fillMaxHeight()) {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.Top) {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3614,11 +3613,11 @@
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.Center) {
Container(
Modifier.align(Alignment.CenterHorizontally).aspectRatio(2f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3626,31 +3625,31 @@
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.Bottom) {
Container(
Modifier.align(Alignment.End).aspectRatio(2f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.align(Alignment.End),
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.SpaceAround) {
- Container(Modifier.fillMaxWidth().aspectRatio(2f), content = emptyContent())
+ Container(Modifier.fillMaxWidth().aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
Modifier.fillMaxWidth(),
- content = emptyContent()
+ content = {}
)
}
},
@Composable {
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.SpaceBetween) {
- Container(Modifier.aspectRatio(2f), content = emptyContent())
+ Container(Modifier.aspectRatio(2f), content = {})
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3658,11 +3657,11 @@
Column(Modifier.fillMaxHeight(), verticalArrangement = Arrangement.SpaceEvenly) {
Container(
Modifier.aspectRatio(2f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(50.toDp(), 40.toDp()),
- content = emptyContent()
+ content = {}
)
}
}
@@ -3700,20 +3699,20 @@
ConstrainedBox(
DpConstraints.fixed(30.toDp(), 20.toDp()),
Modifier.weight(3f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(40.toDp(), 30.toDp()),
Modifier.weight(2f),
- content = emptyContent()
+ content = {}
)
Container(
Modifier.aspectRatio(0.5f).weight(2f),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(30.toDp(), 20.toDp()),
- content = emptyContent()
+ content = {}
)
}
},
@@ -3722,12 +3721,12 @@
ConstrainedBox(
DpConstraints.fixed(30.toDp(), 20.toDp()),
Modifier.weight(3f).align(Alignment.Start),
- content = emptyContent()
+ content = {}
)
ConstrainedBox(
DpConstraints.fixed(40.toDp(), 30.toDp()),
Modifier.weight(2f).align(Alignment.CenterHorizontally),
- content = emptyContent()
+ content = {}
)
Container(Modifier.aspectRatio(0.5f).weight(2f)) { }
ConstrainedBox(
@@ -3964,9 +3963,9 @@
containerHeight.value = coordinates.size.height
positionedLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
- Container(Modifier.weight(1f), content = emptyContent())
+ Container(Modifier.weight(1f), content = {})
}
}
}
@@ -3990,7 +3989,7 @@
modifier = Modifier.alignBy { it.height },
width = size,
height = size,
- content = emptyContent()
+ content = {}
)
Container(
modifier = Modifier.alignBy { 0 }
@@ -4002,7 +4001,7 @@
},
width = size,
height = size,
- content = emptyContent()
+ content = {}
)
}
}
@@ -4085,7 +4084,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4141,7 +4140,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4196,7 +4195,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4249,7 +4248,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4521,7 +4520,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4575,7 +4574,7 @@
coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4628,7 +4627,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4688,7 +4687,7 @@
coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4747,7 +4746,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4817,7 +4816,7 @@
coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4886,7 +4885,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -4954,7 +4953,7 @@
coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -5020,7 +5019,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -5086,7 +5085,7 @@
coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -5149,7 +5148,7 @@
childLayoutCoordinates[i] = coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
@@ -5218,7 +5217,7 @@
coordinates
drawLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
index 5f460cb..2eddbde 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
@@ -17,7 +17,6 @@
package androidx.compose.foundation.layout
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.Providers
import androidx.compose.ui.Alignment
import androidx.compose.ui.layout.Layout
@@ -1295,7 +1294,7 @@
// Clear contents before each test so that we don't recompose the BoxWithConstraints call;
// doing so would recompose the old subcomposition with old constraints in the presence of
// new content before the measurement performs explicit composition the new constraints.
- show(emptyContent())
+ show({})
show {
Layout({
BoxWithConstraints(modifier) {
diff --git a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Spacer.kt b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Spacer.kt
index 6db4f41..46170b4 100644
--- a/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Spacer.kt
+++ b/compose/foundation/foundation-layout/src/commonMain/kotlin/androidx/compose/foundation/layout/Spacer.kt
@@ -17,7 +17,6 @@
package androidx.compose.foundation.layout
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.hasFixedHeight
@@ -33,7 +32,7 @@
*/
@Composable
fun Spacer(modifier: Modifier) {
- Layout(emptyContent(), modifier) { _, constraints ->
+ Layout({}, modifier) { _, constraints ->
with(constraints) {
val width = if (hasFixedWidth) maxWidth else 0
val height = if (hasFixedHeight) maxHeight else 0
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Image.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Image.kt
index 2f8d50d..a97afc2 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Image.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Image.kt
@@ -17,7 +17,6 @@
package androidx.compose.foundation
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.layout.Layout
@@ -184,7 +183,7 @@
// Explicitly use a simple Layout implementation here as Spacer squashes any non fixed
// constraint with zero
Layout(
- emptyContent(),
+ {},
modifier.then(semantics).clipToBounds().paint(
painter,
alignment = alignment,
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
index f847c51..9ff8fdb 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
@@ -22,7 +22,6 @@
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.DisposableEffectResult
import androidx.compose.runtime.DisposableEffectScope
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -148,7 +147,7 @@
Layout(
content = if (inlineComposables.isEmpty()) {
- emptyContent()
+ {}
} else {
{ InlineChildren(text, inlineComposables) }
},
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
index c7801fc..6fb1477 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
@@ -26,7 +26,6 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.currentRecomposeScope
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -460,7 +459,7 @@
.textFieldKeyboardModifier(manager)
SimpleLayout(coreTextFieldModifier) {
- Layout(emptyContent()) { _, constraints ->
+ Layout({ }) { _, constraints ->
TextFieldDelegate.layout(
state.textDelegate,
constraints,
diff --git a/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/lazy/LazyListScrollingBenchmark.kt b/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/lazy/LazyListScrollingBenchmark.kt
index a61b285..696e0be 100644
--- a/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/lazy/LazyListScrollingBenchmark.kt
+++ b/compose/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/lazy/LazyListScrollingBenchmark.kt
@@ -29,7 +29,6 @@
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.testutils.assertNoPendingChanges
import androidx.compose.testutils.benchmark.ComposeBenchmarkRule
import androidx.compose.testutils.doFramesUntilNoChangesPending
@@ -237,7 +236,7 @@
@Composable
fun RemeasurableItem() {
Layout(
- emptyContent(),
+ {},
modifier = object : RemeasurementModifier {
override fun onRemeasurementAvailable(remeasurement: Remeasurement) {
this@ListRemeasureTestCase.remeasurement = remeasurement
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
index 9d74add..91d0050 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
@@ -44,7 +44,6 @@
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -267,7 +266,7 @@
elevation = 4.dp,
color = color,
border = BorderStroke(2.dp, SolidColor(Color.Black.copy(alpha = 0.75f))),
- content = emptyContent()
+ content = {}
)
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerTest.kt
index e2cba15..2389196 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerTest.kt
@@ -22,7 +22,6 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Providers
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.AmbientLayoutDirection
@@ -72,7 +71,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("content"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
@@ -89,7 +88,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("content"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
@@ -107,7 +106,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("content"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
@@ -124,7 +123,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("content"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
@@ -144,7 +143,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("content"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
@@ -164,7 +163,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("drawer"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
@@ -326,7 +325,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("drawer"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
@@ -515,7 +514,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("drawer"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
@@ -554,7 +553,7 @@
drawerContent = {
Box(Modifier.fillMaxSize().testTag("drawer"))
},
- bodyContent = emptyContent()
+ bodyContent = {}
)
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ModalBottomSheetTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ModalBottomSheetTest.kt
index f6e3fab..0858323 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ModalBottomSheetTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ModalBottomSheetTest.kt
@@ -21,7 +21,6 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.preferredHeight
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertTopPositionInRootIsEqualTo
@@ -66,7 +65,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden),
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -88,7 +87,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Expanded),
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -110,7 +109,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden),
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -131,7 +130,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Expanded),
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -151,7 +150,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = rememberModalBottomSheetState(ModalBottomSheetValue.HalfExpanded),
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -173,7 +172,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = sheetState,
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -215,7 +214,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = sheetState,
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -256,7 +255,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = sheetState,
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -288,7 +287,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = sheetState,
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
@@ -319,7 +318,7 @@
rule.setMaterialContent {
ModalBottomSheetLayout(
sheetState = sheetState,
- content = emptyContent(),
+ content = {},
sheetContent = {
Box(
Modifier
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
index 94b26c2..59074a7 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
@@ -22,7 +22,6 @@
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredSize
-import androidx.compose.runtime.emptyContent
import androidx.compose.testutils.assertPixels
import androidx.compose.testutils.assertShape
import androidx.compose.ui.Modifier
@@ -115,7 +114,7 @@
Modifier.fillMaxSize().padding(2.dp),
elevation = 2.dp,
color = Color.Blue,
- content = emptyContent()
+ content = {}
)
}
@@ -132,7 +131,7 @@
Modifier.fillMaxSize().padding(2.dp),
elevation = 2.dp,
color = Color.Blue,
- content = emptyContent()
+ content = {}
)
}
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt
index 8d9a5a9..3144396 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Scaffold.kt
@@ -22,7 +22,6 @@
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Providers
import androidx.compose.runtime.Stable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticAmbientOf
import androidx.compose.ui.Modifier
@@ -148,10 +147,10 @@
fun Scaffold(
modifier: Modifier = Modifier,
scaffoldState: ScaffoldState = rememberScaffoldState(),
- topBar: @Composable () -> Unit = emptyContent(),
- bottomBar: @Composable () -> Unit = emptyContent(),
+ topBar: @Composable () -> Unit = {},
+ bottomBar: @Composable () -> Unit = {},
snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost(it) },
- floatingActionButton: @Composable () -> Unit = emptyContent(),
+ floatingActionButton: @Composable () -> Unit = {},
floatingActionButtonPosition: FabPosition = FabPosition.End,
isFloatingActionButtonDocked: Boolean = false,
drawerContent: @Composable (ColumnScope.() -> Unit)? = null,
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
index 4b7e40a..79e179e 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
@@ -35,7 +35,6 @@
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
@@ -180,7 +179,7 @@
indication = rememberRipple(bounded = false, radius = ThumbRippleRadius)
)
.size(ThumbDiameter),
- content = emptyContent()
+ content = {}
)
}
diff --git a/compose/runtime/runtime/api/current.txt b/compose/runtime/runtime/api/current.txt
index 833d1e5..9a7f3d7 100644
--- a/compose/runtime/runtime/api/current.txt
+++ b/compose/runtime/runtime/api/current.txt
@@ -79,8 +79,8 @@
}
public final class ComposeKt {
- method @androidx.compose.runtime.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
- method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
+ method @Deprecated @androidx.compose.runtime.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
+ method @Deprecated public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
}
public final class ComposeNodeKt {
@@ -597,7 +597,7 @@
public final class ComposableLambdaKt {
method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambda(androidx.compose.runtime.Composer composer, int key, boolean tracked, String? sourceInformation, Object block);
- method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambdaInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambdaInstance(int key, boolean tracked, String? sourceInformation, Object block);
}
@androidx.compose.runtime.ComposeCompilerApi @androidx.compose.runtime.Stable public final class ComposableLambdaN<R> implements kotlin.jvm.functions.FunctionN<R> {
diff --git a/compose/runtime/runtime/api/public_plus_experimental_current.txt b/compose/runtime/runtime/api/public_plus_experimental_current.txt
index 833d1e5..9a7f3d7 100644
--- a/compose/runtime/runtime/api/public_plus_experimental_current.txt
+++ b/compose/runtime/runtime/api/public_plus_experimental_current.txt
@@ -79,8 +79,8 @@
}
public final class ComposeKt {
- method @androidx.compose.runtime.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
- method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
+ method @Deprecated @androidx.compose.runtime.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
+ method @Deprecated public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
}
public final class ComposeNodeKt {
@@ -597,7 +597,7 @@
public final class ComposableLambdaKt {
method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambda(androidx.compose.runtime.Composer composer, int key, boolean tracked, String? sourceInformation, Object block);
- method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambdaInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambdaInstance(int key, boolean tracked, String? sourceInformation, Object block);
}
@androidx.compose.runtime.ComposeCompilerApi @androidx.compose.runtime.Stable public final class ComposableLambdaN<R> implements kotlin.jvm.functions.FunctionN<R> {
diff --git a/compose/runtime/runtime/api/restricted_current.txt b/compose/runtime/runtime/api/restricted_current.txt
index 07e1499..fe8de7f 100644
--- a/compose/runtime/runtime/api/restricted_current.txt
+++ b/compose/runtime/runtime/api/restricted_current.txt
@@ -80,8 +80,8 @@
}
public final class ComposeKt {
- method @androidx.compose.runtime.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
- method public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
+ method @Deprecated @androidx.compose.runtime.Stable public static kotlin.jvm.functions.Function0<kotlin.Unit> emptyContent();
+ method @Deprecated public static inline kotlin.jvm.functions.Function0<kotlin.Unit> orEmpty(kotlin.jvm.functions.Function0<kotlin.Unit>?);
}
public final class ComposeNodeKt {
@@ -624,7 +624,7 @@
public final class ComposableLambdaKt {
method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambda(androidx.compose.runtime.Composer composer, int key, boolean tracked, String? sourceInformation, Object block);
- method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambdaInstance(int key, boolean tracked, Object block);
+ method @androidx.compose.runtime.ComposeCompilerApi public static androidx.compose.runtime.internal.ComposableLambda<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object> composableLambdaInstance(int key, boolean tracked, String? sourceInformation, Object block);
}
@androidx.compose.runtime.ComposeCompilerApi @androidx.compose.runtime.Stable public final class ComposableLambdaN<R> implements kotlin.jvm.functions.FunctionN<R> {
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Compose.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Compose.kt
index c042129..68f5550 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Compose.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Compose.kt
@@ -24,10 +24,18 @@
* See [orEmpty] for handling nullable Composable lambdas using empty content.
*/
@Stable
+@Deprecated(
+ "An empty lambda literal is preferred",
+ replaceWith = ReplaceWith("{}")
+)
fun emptyContent() = EmptyComposable
/**
* @return this Composable if not null, else [emptyContent].
*/
-@Suppress("NOTHING_TO_INLINE")
+@Suppress("NOTHING_TO_INLINE", "DEPRECATION")
+@Deprecated(
+ "Use the null coalescing operator instead",
+ replaceWith = ReplaceWith("this ?: {}")
+)
inline fun (@Composable (() -> Unit))?.orEmpty() = this ?: emptyContent()
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composition.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composition.kt
index 2d3cbee..7152d2a 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composition.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/Composition.kt
@@ -258,7 +258,7 @@
private var disposed = false
- var composable: @Composable () -> Unit = emptyContent()
+ var composable: @Composable () -> Unit = {}
override val isComposing: Boolean
get() = composer.isComposing
@@ -282,7 +282,7 @@
override fun dispose() {
if (!disposed) {
disposed = true
- composable = emptyContent()
+ composable = {}
composer.dispose()
parent.unregisterComposition(this)
onDispose?.invoke()
@@ -370,7 +370,7 @@
state.clear()
val holders = Compositions.collectAll()
holders.mapTo(state) { it to it.composable }
- holders.filter { it.isRoot }.forEach { it.setContent(emptyContent()) }
+ holders.filter { it.isRoot }.forEach { it.setContent({}) }
}
// Called after Dex Code Swap
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/internal/ComposableLambda.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/internal/ComposableLambda.kt
index 562802f..d1583aa 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/internal/ComposableLambda.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/internal/ComposableLambda.kt
@@ -1210,5 +1210,5 @@
@Suppress("unused")
@ComposeCompilerApi
-fun composableLambdaInstance(key: Int, tracked: Boolean, block: Any) =
- CLambda(key, tracked, null).apply { update(block) }
+fun composableLambdaInstance(key: Int, tracked: Boolean, sourceInformation: String?, block: Any) =
+ CLambda(key, tracked, sourceInformation).apply { update(block) }
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/BoundsTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/BoundsTest.kt
index b4a14e6..aec5e08 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/BoundsTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/BoundsTest.kt
@@ -124,7 +124,7 @@
}
}.flatten().groupBy { it.location }
- Assert.assertTrue(boundingBoxes.size >= 6)
+ Assert.assertTrue(boundingBoxes.size >= 4)
}
}
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
index e096248..1bdff85 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/inspector/ParameterFactoryTest.kt
@@ -239,7 +239,9 @@
@Test
fun testComposableLambda() = runBlocking {
- val c: @Composable () -> Unit = { Text(text = "Hello World") }
+ // capture here to force the lambda to not be created as a singleton.
+ val capture = "Hello World"
+ val c: @Composable () -> Unit = { Text(text = capture) }
val result = lookup(c as Any) ?: error("Lookup of ComposableLambda failed")
val array = result.second as Array<*>
assertThat(result.first).isEqualTo(ParameterType.Lambda)
diff --git a/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt b/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt
index 23d854c..92237c6 100644
--- a/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt
+++ b/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt
@@ -33,7 +33,6 @@
import androidx.compose.runtime.Providers
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.currentComposer
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.ui.graphics.Color
@@ -60,6 +59,8 @@
const val TOOLS_NS_URI = "http://schemas.android.com/tools"
+private val emptyContent: @Composable () -> Unit = @Composable {}
+
/**
* Class containing the minimum information needed by the Preview to map components to the
* source code and render boundaries.
@@ -146,14 +147,14 @@
* The [Composable] to be rendered in the preview. It is initialized when this adapter
* is initialized.
*/
- private var previewComposition: @Composable () -> Unit = emptyContent()
+ private var previewComposition: @Composable () -> Unit = {}
- // Note: the call to emptyContent() below instead of a literal {} works around
+ // Note: the constant emptyContent below instead of a literal {} works around
// https://youtrack.jetbrains.com/issue/KT-17467, which causes the compiler to emit classes
// named `content` and `Content` (from the Content method's composable update scope)
// which causes compilation problems on case-insensitive filesystems.
@Suppress("RemoveExplicitTypeArguments")
- private val content = mutableStateOf<@Composable () -> Unit>(emptyContent())
+ private val content = mutableStateOf<@Composable () -> Unit>(emptyContent)
/**
* When true, the composition will be immediately invalidated after being drawn. This will
@@ -334,7 +335,7 @@
private fun invalidateComposition() {
// Invalidate the full composition by setting it to empty and back to the actual value
- content.value = emptyContent()
+ content.value = {}
content.value = previewComposition
// Invalidate the state of the view so it gets redrawn
invalidate()
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/NestedPressDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/NestedPressDemo.kt
index f0834bc..127a50b 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/NestedPressDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/NestedPressDemo.kt
@@ -26,7 +26,6 @@
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
@@ -62,7 +61,7 @@
@Composable
private fun PressableContainer(
modifier: Modifier = Modifier,
- content: @Composable () -> Unit = emptyContent()
+ content: @Composable () -> Unit = {}
) {
val defaultColor = DefaultBackgroundColor
val pressedColor = PressedColor
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
index 29765cf..e63b42f 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
@@ -25,7 +25,6 @@
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
@@ -65,7 +64,7 @@
orientation: Orientation,
activeColor: Color,
idleColor: Color,
- content: @Composable () -> Unit = emptyContent()
+ content: @Composable () -> Unit = {}
) {
val color = remember { mutableStateOf(idleColor) }
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
index 1a02253..4eca29f 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
@@ -41,7 +41,6 @@
import androidx.compose.runtime.Providers
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -534,7 +533,7 @@
assertEquals(childConstraints[0], constraints)
layout(0, 0) {}
},
- content = emptyContent(), modifier = Modifier.layoutId("header")
+ content = {}, modifier = Modifier.layoutId("header")
)
}
val footer = @Composable {
@@ -543,14 +542,14 @@
assertEquals(childConstraints[1], constraints)
layout(0, 0) {}
},
- content = emptyContent(), modifier = Modifier.layoutId("footer")
+ content = {}, modifier = Modifier.layoutId("footer")
)
Layout(
measureBlock = { _, constraints ->
assertEquals(childConstraints[2], constraints)
layout(0, 0) {}
},
- content = emptyContent(), modifier = Modifier.layoutId("footer")
+ content = {}, modifier = Modifier.layoutId("footer")
)
}
@@ -1812,7 +1811,7 @@
activity.setContent {
Layout(
content = {
- Layout(content = emptyContent()) { _, _ ->
+ Layout(content = {}) { _, _ ->
latch.countDown()
layout(model.size, model.size) {}
}
@@ -1844,7 +1843,7 @@
content = {
Layout(
modifier = Modifier.graphicsLayer(),
- content = emptyContent()
+ content = {}
) { _, _ ->
latch.countDown()
layout(model.size, model.size) {}
@@ -2379,7 +2378,7 @@
}
layout(100, 100) {}
}
- FixedSize(30, content = emptyContent())
+ FixedSize(30, content = {})
}
) { measurables, constraints ->
val (first, second) = measurables
@@ -3599,7 +3598,7 @@
fun AtLeastSize(
size: Int,
modifier: Modifier = Modifier,
- content: @Composable () -> Unit = emptyContent()
+ content: @Composable () -> Unit = {}
) {
Layout(
measureBlock = { measurables, constraints ->
@@ -3641,7 +3640,7 @@
fun FixedSize(
size: Int,
modifier: Modifier = Modifier,
- content: @Composable () -> Unit = emptyContent()
+ content: @Composable () -> Unit = {}
) {
Layout(content = content, modifier = modifier) { measurables, _ ->
val newConstraints = Constraints.fixed(size, size)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/OpenComposeView.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/OpenComposeView.kt
index 9f9e5a6..ece2f94 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/OpenComposeView.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/OpenComposeView.kt
@@ -19,7 +19,6 @@
import android.content.Context
import android.util.AttributeSet
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.platform.AbstractComposeView
@@ -31,7 +30,7 @@
) : AbstractComposeView(context, attrs, defStyleAttr) {
@Suppress("RemoveExplicitTypeArguments")
- private val content = mutableStateOf<@Composable () -> Unit>(emptyContent())
+ private val content = mutableStateOf<@Composable () -> Unit>({})
@Composable
override fun Content() {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/ParentDataModifierTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/ParentDataModifierTest.kt
index 20e1323..6eb6703 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/ParentDataModifierTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/ParentDataModifierTest.kt
@@ -16,7 +16,6 @@
package androidx.compose.ui
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.Layout
@@ -116,13 +115,13 @@
val header = @Composable {
Layout(
modifier = Modifier.layoutId(0),
- content = emptyContent()
+ content = {}
) { _, _ -> layout(0, 0) {} }
}
val footer = @Composable {
Layout(
modifier = Modifier.layoutId(1),
- content = emptyContent()
+ content = {}
) { _, _ -> layout(0, 0) {} }
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawReorderingTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawReorderingTest.kt
index 4cf87b1..7d21101 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawReorderingTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawReorderingTest.kt
@@ -22,7 +22,6 @@
import android.view.ViewTreeObserver
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -1046,7 +1045,7 @@
private fun FixedSize(
size: State<Int>,
modifier: Modifier = Modifier,
- content: @Composable () -> Unit = emptyContent()
+ content: @Composable () -> Unit = {}
) {
Layout(content = content, modifier = modifier) { measurables, _ ->
val newConstraints = Constraints.fixed(size.value, size.value)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/gesture/LongPressDragGestureFilterTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/gesture/LongPressDragGestureFilterTest.kt
index 9e12c1b..11f062a 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/gesture/LongPressDragGestureFilterTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/gesture/LongPressDragGestureFilterTest.kt
@@ -19,7 +19,6 @@
import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.layout.Box
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.layout.Layout
@@ -85,7 +84,7 @@
setupLatch.countDown()
}
},
- content = emptyContent()
+ content = {}
)
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/AndroidPointerInputTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/AndroidPointerInputTest.kt
index 8a987ae..3ff7e74 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/AndroidPointerInputTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/AndroidPointerInputTest.kt
@@ -23,7 +23,6 @@
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ExperimentalComposeApi
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -591,7 +590,7 @@
@Suppress("TestFunctionName")
@Composable
private fun FillLayout(modifier: Modifier = Modifier) {
- Layout(emptyContent(), modifier) { _, constraints ->
+ Layout({}, modifier) { _, constraints ->
layout(constraints.maxWidth, constraints.maxHeight) {}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/ClipPointerInputTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/ClipPointerInputTest.kt
index fa5a9be..3d6a2c6 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/ClipPointerInputTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/ClipPointerInputTest.kt
@@ -21,7 +21,6 @@
import android.view.ViewGroup
import androidx.compose.foundation.layout.offset
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.geometry.Offset
@@ -316,7 +315,7 @@
@Composable
fun Child(modifier: Modifier) {
- Layout(content = emptyContent(), modifier = modifier) { _, _ ->
+ Layout(content = {}, modifier = modifier) { _, _ ->
layout(2, 2) {}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
index 2579115..d492eac 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
@@ -23,7 +23,6 @@
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
@@ -151,7 +150,7 @@
}
@Composable
-fun SimpleLayout(modifier: Modifier, content: @Composable () -> Unit = emptyContent()) {
+fun SimpleLayout(modifier: Modifier, content: @Composable () -> Unit = {}) {
Layout(
content,
modifier
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
index bac20cd..8d0b574 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
@@ -26,7 +26,6 @@
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -661,7 +660,7 @@
fun DelayedMeasure(
size: Int,
modifier: Modifier = Modifier,
- content: @Composable () -> Unit = emptyContent()
+ content: @Composable () -> Unit = {}
) {
Layout(content = content, modifier = modifier) { measurables, _ ->
layout(size, size) {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
index 06f92fe..7ea1393 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
@@ -22,7 +22,6 @@
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Providers
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.FixedSize
import androidx.compose.ui.Modifier
@@ -261,7 +260,7 @@
Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
Box {
Providers(AmbientLayoutDirection provides initialLayoutDirection) {
- Layout(emptyContent()) { _, _ ->
+ Layout({}) { _, _ ->
resultLayoutDirection.value = layoutDirection
latch.countDown()
layout(0, 0) {}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/LayoutIdTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/LayoutIdTest.kt
index 459bc94..f1311c7 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/LayoutIdTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/LayoutIdTest.kt
@@ -17,7 +17,6 @@
package androidx.compose.ui.platform
import androidx.compose.foundation.layout.Box
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.AtLeastSize
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
@@ -63,15 +62,15 @@
activity.setContent {
Layout(
{
- AtLeastSize(0, Modifier.layoutId("first"), content = emptyContent())
+ AtLeastSize(0, Modifier.layoutId("first"), content = {})
Box(Modifier.layoutId("second")) {
AtLeastSize(
0,
- content = emptyContent()
+ content = {}
)
}
Box(Modifier.layoutId("third")) {
- AtLeastSize(0, content = emptyContent())
+ AtLeastSize(0, content = {})
}
}
) { measurables, _ ->
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogSecureFlagTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogSecureFlagTest.kt
index 0a89378..0e2c070 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogSecureFlagTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogSecureFlagTest.kt
@@ -21,7 +21,6 @@
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -116,7 +115,7 @@
onDismissRequest = { },
properties = dialogProperties
) {
- SimpleContainer(Modifier.preferredSize(50.dp), content = emptyContent())
+ SimpleContainer(Modifier.preferredSize(50.dp), content = {})
}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupAlignmentTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupAlignmentTest.kt
index 755f8fe..a0de7cc 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupAlignmentTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupAlignmentTest.kt
@@ -19,7 +19,6 @@
import android.view.View
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Providers
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
@@ -332,7 +331,7 @@
modifier = Modifier.onGloballyPositioned {
measureLatch.countDown()
},
- content = emptyContent()
+ content = {}
)
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupSecureFlagTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupSecureFlagTest.kt
index 8e4fdd6..95d7e63 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupSecureFlagTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupSecureFlagTest.kt
@@ -20,7 +20,6 @@
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -123,7 +122,7 @@
alignment = Alignment.Center,
properties = popupProperties
) {
- SimpleContainer(Modifier.preferredSize(50.dp), content = emptyContent())
+ SimpleContainer(Modifier.preferredSize(50.dp), content = {})
}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
index 7568a99..207aed8 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
@@ -23,7 +23,6 @@
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Providers
import androidx.compose.runtime.ambientOf
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
@@ -81,7 +80,7 @@
SimpleContainer {
PopupTestTag(testTag) {
Popup(alignment = Alignment.Center) {
- SimpleContainer(Modifier.preferredSize(50.dp), content = emptyContent())
+ SimpleContainer(Modifier.preferredSize(50.dp), content = {})
}
}
}
@@ -106,7 +105,7 @@
SimpleContainer(
width = popupWidthDp,
height = popupHeightDp,
- content = emptyContent()
+ content = {}
)
}
}
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
index ad973be..988c6f0 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
@@ -31,7 +31,6 @@
import androidx.compose.runtime.Providers
import androidx.compose.runtime.Recomposer
import androidx.compose.runtime.currentComposer
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.tooling.InspectionTables
import androidx.compose.ui.R
import androidx.compose.ui.node.LayoutNode
@@ -166,7 +165,7 @@
private var disposed = false
private var addedToLifecycle: Lifecycle? = null
- private var lastContent: @Composable () -> Unit = emptyContent()
+ private var lastContent: @Composable () -> Unit = {}
@OptIn(InternalComposeApi::class)
override fun setContent(content: @Composable () -> Unit) {
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.kt
index ceb4cf9..6779455 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.kt
@@ -31,7 +31,6 @@
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.SideEffect
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -161,7 +160,7 @@
override val window: Window
) : AbstractComposeView(context), DialogWindowProvider {
- private var content: @Composable () -> Unit by mutableStateOf(emptyContent())
+ private var content: @Composable () -> Unit by mutableStateOf({})
protected override var shouldCreateCompositionOnAttachedToWindow: Boolean = false
private set
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.kt
index a600e95..050c347 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.kt
@@ -33,7 +33,6 @@
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.derivedStateOf
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -176,7 +175,7 @@
// used instead of this custom Layout
// Get the parent's position, size and layout direction
Layout(
- content = emptyContent(),
+ content = {},
modifier = Modifier.onGloballyPositioned { childCoordinates ->
val coordinates = childCoordinates.parentLayoutCoordinates!!
val layoutSize = coordinates.size
@@ -289,7 +288,7 @@
windowManager.addView(this, params)
}
- private var content: @Composable () -> Unit by mutableStateOf(emptyContent())
+ private var content: @Composable () -> Unit by mutableStateOf({})
override var shouldCreateCompositionOnAttachedToWindow: Boolean = false
private set
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
index 73c2797..d2777f9 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
@@ -24,7 +24,6 @@
import androidx.compose.runtime.RememberObserver
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.ComposeNode
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCompositionReference
import androidx.compose.ui.Modifier
@@ -148,7 +147,7 @@
currentIndex++
val nodeState = nodeToNodeState.getOrPut(node) {
- NodeState(slotId, emptyContent())
+ NodeState(slotId, {})
}
val hasPendingChanges = nodeState.composition?.hasInvalidations ?: true
if (nodeState.content !== content || hasPendingChanges) {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/selection/SelectionHandles.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/selection/SelectionHandles.kt
index 5a98035..67ff734 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/selection/SelectionHandles.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/selection/SelectionHandles.kt
@@ -17,7 +17,6 @@
package androidx.compose.ui.selection
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.emptyContent
import androidx.compose.runtime.remember
import androidx.compose.ui.AbsoluteAlignment
import androidx.compose.ui.Alignment
@@ -187,7 +186,7 @@
height: Dp,
onCanvas: DrawScope.() -> Unit
) {
- Layout(emptyContent(), modifier.drawBehind(onCanvas)) { _, _ ->
+ Layout({}, modifier.drawBehind(onCanvas)) { _, _ ->
// take width and height space of the screen and allow draw modifier to draw inside of it
layout(width.toIntPx(), height.toIntPx()) {
// this layout has no children, only draw modifier.
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.kt
index 210fa44..2ccac3f 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.kt
@@ -19,7 +19,6 @@
import androidx.compose.runtime.CompositionReference
import androidx.compose.runtime.Providers
import androidx.compose.runtime.ambientOf
-import androidx.compose.runtime.emptyContent
import androidx.compose.ui.platform.Keyboard
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
@@ -69,7 +68,7 @@
resizable: Boolean = true,
events: WindowEvents = WindowEvents(),
onDismissRequest: (() -> Unit)? = null,
- content: @Composable () -> Unit = emptyContent()
+ content: @Composable () -> Unit = { }
) = SwingUtilities.invokeLater {
AppWindow(
title = title,