min
05/17/2026, 8:25 AMx: Int if I call A()?min
05/17/2026, 9:37 AM0? Because it’s the bottom value?
class MyClass(/* ... */)
@Composable fun MyComposable(
myClass: MyClass = MyClass(/* ... */),
) {/* ... */}
What about types without a defined bottom value? What‘s passed to myClass if I call MyComposable()?Oleksandr Balan
05/17/2026, 10:13 AMnull, see this example with JvmOverloads here: https://medium.com/@debuggingisfun/kotlin-default-parameter-values-5b0046664c0cursus
05/18/2026, 8:05 AMmin
05/18/2026, 11:57 AM@Composable functions too?Oleksandr Balan
05/18/2026, 12:19 PM@Composable
fun Foo() {
Bar()
}
@Composable
fun Bar(a: MyClass = MyClass(42)) {
// Empty
}
class MyClass(
val value: Int,
)
Decompiled bytecode looks like this:
@Composable
public static final void Foo(@Nullable Composer $composer, int $changed) {
...
Bar((MyClass)null, $composer, 0, 1);
...
}
@Composable
public static final void Bar(@Nullable MyClass a, @Nullable Composer $composer, int $changed, int var3) {
...
if ((var3 & 1) != 0) {
a = new MyClass(42);
...
}
...
}min
06/24/2026, 12:21 PMmin
06/24/2026, 12:22 PM@Composable
fun LocalDemo(modifier: Modifier = Modifier) {
val state = remember { mutableIntStateOf(0) }
Column(modifier = modifier) {
Text("Tapped ${state.intValue} times.")
Button(onClick = { state.intValue += 1 }) {
Text("Tap")
}
}
val tracked = compositionLocalOf { 0 }
val untracked = staticCompositionLocalOf { 0 }
CompositionLocalProvider(tracked provides state.intValue) {
Log.d("LOCALDEMO", "provider where `tracked provides state.intValue`")
}
CompositionLocalProvider(untracked provides state.intValue) {
Log.d("LOCALDEMO", "provider where `untracked provides state.intValue`")
}
}Oleksandr Balan
06/24/2026, 1:02 PMLog.d with println, as I am using CMP projectmin
06/25/2026, 8:49 AMOleksandr Balan
06/25/2026, 10:15 AMmin
06/26/2026, 12:42 PM