litho
litho copied to clipboard
@PropDefault problem on kotlin 1.4.10
- [ ] I have searched existing issues and this is not a duplicate
Version
0.38.0
Issues and Steps to Reproduce
After upgrate kotlin to 1.4.10 can't build project because of the problem below:
it goes from @PropDefault value. Removing it solves the problem, but I'd like to use it)
@colriot take a look, please)
Hi @TimurKhairnasov ! Yep, seems that it's happening due to the new synthetics methods generation behaviour: https://kotlinlang.org/docs/reference/compatibility-guide-14.html#kapt-names-of-synthetic-annotations-methods-for-properties-have-changed
To mitigate this you can mark @PropfDefault
fields as @JvmField
, it will fix the compilation
@colriot, compilation has fixed, but default values are not setting up. Int value is 0, despite of PropDefault value.
- for VerticalGravity value error: Parameter specified as non-null is null
I have the same issue 😕 , @TimurKhairnasov have you found a workaround?
Ok, I have found a workaround, after seeing this:
https://github.com/facebook/litho/blob/bad7023f2668882a9d01525676d8ef868ce06f09/litho-processor/src/main/java/com/facebook/litho/specmodels/processor/PropDefaultsExtractor.java#L111
Change all @PropDefaut
with @get:PropDefault
and it should work.
I checked generated Component
and they look the same before (kotlin 1.3.72 and @PropDefaut
) and after (kotlin 1.4.10 and @get:PropDefaut
).
(thanks @tychota for pointing me in the right direction) 🥳
Well hello there 😄 I remember the days I was fixing this 😂 @colriot should I give it a try and port it to the new behavior?
@tpucci helped me too, thanks!