Litho: @PropDefault problem on kotlin 1.4.10

Created on 29 Oct 2020  路  6Comments  路  Source: facebook/litho

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)

Most helpful comment

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) 馃コ

All 6 comments

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
    image

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hussainahmad picture hussainahmad  路  3Comments

doublechina picture doublechina  路  3Comments

pavlospt picture pavlospt  路  5Comments

ooga picture ooga  路  7Comments

Syne10 picture Syne10  路  6Comments