Stylianos Gakis
09/20/2022, 7:25 AM@Immutable
@JvmInline
value class Foo(val values: Set<Int>)
And when generating compose metrics this gets read as unstable
. When removing the @JvmInline
and the value
from it, and keeping the @Immutable
(or @Stable
) it does in fact get inferred as stable looking at the generated files. This must be a bug right?Zoltan Demant
09/20/2022, 7:35 AMFoo
in a composable function would be identical to specifying Set<Int>
, which is unstable. It would be awesome if this somehow worked though, I made a post about it a while back - feel free to star it!
You can "work around it" by creating an interface, marked with @Immutable
which under the hood is implemented by an inline class. Ive done this a ton and it works great, but theres a lot more code to write and maintain!Stylianos Gakis
09/20/2022, 7:40 AMSet
since it’s inline, but I was hoping since the class itself is marked as stable that it would work, just like it does if we make our own class to wrap the unstable thing and mark its stability ourselves.
But yeah, good to know that this is how it currently works at least, let’s see if this changes sometime in the future :Dste
09/20/2022, 7:41 AM@Immutable
@JvmInline
value class Bar(val value: String)
was considered unstable
tooStylianos Gakis
09/20/2022, 9:47 AMfun
@Composable
fun Foo(bar: Bar) {
Text(bar.toString())
}
Where Bar
@Immutable
@JvmInline
value class Bar(val value: String)
I get
restartable scheme("[androidx.compose.ui.UiComposable]") fun Foo(
unstable bar: Bar
)
Zoltan Demant
09/20/2022, 10:36 AMStylianos Gakis
09/20/2022, 12:43 PM@Immutable
I get this
restartable scheme("[androidx.compose.ui.UiComposable]") fun Foo(
unstable bar: Bar
)