https://kotlinlang.org logo
#compose
Title
# compose
m

mattinger

06/06/2022, 6:50 PM
Does anyone know if there’s a limit to the # of arguments in a data class? We have a custom theme that has like 160 or so different colors (technically it’s like 40 tokens, but each has a value for base, hover, focus and down), and now i’m getting this error at runtime:
Copy code
Rejecting invocation, expected 79 argument registers, method signature has 81 or more
If i group the sets of 4 into their own data classes and pass that in instead of as 4 separate parameters, things seem to start working again. What’s odd is that there’s actually 166 parameters to the constructor (yeah, i know, blame the design team for creating so many color tokens)
🤯 7
👀 1
n

Norbi

06/06/2022, 7:32 PM
Idk the answer :) But you may store them in a
Map
and access them using delegated properties if you need dedicated accessor for each value.
2
n

natario1

06/06/2022, 9:08 PM
I hit a similar error message when dealing with a lambda with more than 10 parameters or so. So I don’t know for sure, but I think compose compiler definitely has some hardcoded limits (or some bug).
m

mattinger

06/06/2022, 9:16 PM
I’m not convinced it’s the compose compiler @natario1. This particular function it’s calling isn’t a composable function. It’s part of a composition local, which, while goverened by the compose lifeycle, isn’t in and of itself a composable.
n

natario1

06/06/2022, 9:18 PM
I don’t know for sure. But the argument offset (79 vs 81) is suspicious - IIRC, the compose compiler injects 2 extra parameters into composable functions.
t

Tash

06/06/2022, 11:51 PM
But you may store them in a
Map
and access them using delegated properties if you need dedicated accessor for each value.
+++1 we’re doing this right now and its working out well
m

mattinger

06/13/2022, 2:19 PM
This ended up being an ART/JVM limitiation. We’re restructuring our arguments to put them into logical sets of color groups, since there is some inherent structure there (fill/stroke/text).
40 Views