Does anyone know if there’s a limit to the # of ar...
# compose
m
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
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
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
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
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
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
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).