litho icon indicating copy to clipboard operation
litho copied to clipboard

@PropDefault problem on kotlin 1.4.10

Open TimurKhairnasov opened this issue 4 years ago • 6 comments

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: image

it goes from @PropDefault value. Removing it solves the problem, but I'd like to use it)

@colriot take a look, please)

TimurKhairnasov avatar Oct 29 '20 06:10 TimurKhairnasov

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 avatar Oct 29 '20 21:10 colriot

@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 image

TimurKhairnasov avatar Oct 30 '20 04:10 TimurKhairnasov

I have the same issue 😕 , @TimurKhairnasov have you found a workaround?

tpucci avatar Nov 11 '20 14:11 tpucci

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) 🥳

tpucci avatar Nov 11 '20 15:11 tpucci

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?

pavlospt avatar Nov 11 '20 16:11 pavlospt

@tpucci helped me too, thanks!

TimurKhairnasov avatar Nov 16 '20 05:11 TimurKhairnasov