Question about function resolution and context par...
# compose
z
Question about function resolution and context parameters: In Kotlin 2.4.10, the compiler is unable to distinguish between a composable function and a non-composable function that has context parameters but otherwise the same name. E.g.:
Copy code
@Composable
fun foo() = doSomething(LocalResources.current)
and
Copy code
context(reader: CompositionLocalConsumerModifierNode)
fun foo() = doSomething(reader.currentValueOf(LocalResources))
This is unfortunate, since it seems like the compiler has enough information to clearly distinguish them in any case except when called from inside a composable where the context param type is also available, and in that case an ambiguity error would be fine (in my example, many things would have gone wrong to get to that point anyway). I thought I saw that Kotlin made a change closer to the stabilization of context params that stopped using them to distinguish functions in resolution, and I'm sure they had good reasons to do so. But I would hope that context params and function color together would be sufficient. So I suspect this is a limitation of how context parameters are implemented and not something the Compose compiler can fix.
s
We only color lambdas and not regular functions for the type system, regular calls are just handled by a call checker. Can you file a bug for this?
👍🏻 1
z