Now I’m deeply confused how modifier chaining and ...
# compose
p
Now I’m deeply confused how modifier chaining and kotlin in general works 🤔 There is a new lint: https://googlesamples.github.io/android-custom-lint-rules/checks/ModifierFactoryUnreferencedReceiver.md.html And it says that here the original modifier is unused:
Copy code
private fun Modifier.unicorns() : Modifier = background(Color.Red)
But is it really?
s
I had this warning some time ago, but it disappeared again. It seems like a bug to me.
background(Color.Red)
is just
this.background(Color.Red)
, which does indeed reference the original modifier (
this
).
p
It’s very weird
s
The warning is probably to warn you if you were to do something like this:
Copy code
private fun Modifier.unicorns() : Modifier = Modifier.background(Color.Red)
p
Yeah that makes absolute sense
s
I'm pretty sure it's a bug in the lint check.
p
Yeah me too. Just wondered if there was something fundamentally I don’t understand
s
It could be related to this one, perhaps? https://issuetracker.google.com/issues/187539461
h
You can use .then(//something modifierish)
p
Yes that’s what its saying. The question is: Is it necessary
h
.then does strict equality check if the modifier is the same otherwise it combines the one that's a receiver and the parameter one, I think that might be an optimization in place that they want us to use
e
Its a lint bug.