inline function from a Composable context, why is the selector lambda not also in a Composable context?
Copy code
// in a composable context
items.sortedBy {
// not in a composable context
...
}
As a workaround, I suppose I should build a map of these lambda values and then refer to the map from within the lambda.
r
romainguy
12/16/2023, 5:21 AM
Even though it's inlined the type of the lambda is not @Composable
m
Mark
12/16/2023, 5:22 AM
Thanks Romain. IIRC this is different from suspend functions in that the lambda arg does not need to be declared as a suspend function?
r
romainguy
12/16/2023, 5:26 AM
Folks like @jim can give you better answers than I can. But I wouldn't be surprised if it's because of where inlining happens (afaik before K2 it's done at the bytecode level)
👍 1
m
Mark
12/16/2023, 5:29 AM
I guess it’s related to
crossinline
because there is no such problem with
map
or
associateWith
s
shikasd
12/16/2023, 2:03 PM
Yeah, we support inlining, but not crossinlining, since that can escape composable context
Technically, if suspend lambdas support that, Compose likely should too, feel free to file a bug
👍 2
m
Mark
12/16/2023, 2:08 PM
I just checked, and it’s the same (as composable) for suspending lambdas. So no need to file an issue.