contentful / vault

Easy persistence of Contentful data for Android over SQLite.
https://contentful.github.io/vault/
Apache License 2.0
85 stars 19 forks source link

@Field List<Resources> is not process correctly by kapt / vault compiler #140

Closed kzotin closed 5 years ago

kzotin commented 6 years ago

Hi folks, Sorry, it's me again :)

After migrating Vault models to Kotlin, we're facing issue with List<Resources> field. We're declaring field in following way: @JvmField @Field var content: List<Resource>? = null

FAILURE: Build failed with an exception:

Invalid list type "? extends com.contentful.vault.Resource" specified

Possible cause: https://github.com/contentful/vault/blob/master/compiler/src/main/java/com/contentful/vault/compiler/Processor.java#L284

mariobodemann commented 6 years ago

Hello again, :)

since our support for Kotlin is in its infants, I would need a bit more time to find out what this means for us and how we can make this work™. I would kindly ask you to give me like a week and I gladly will come back with an idea...

Would you have a suggestion on how to approach the problem?

Greetings, Mario

kzotin commented 6 years ago

My quick guess is that with java List type is passed to compiler as: List<Resource> With Kotlin it's more explicit: List<? extends com.contentful.vault.Resource>.

And then some dark magic is happening here which returns false for kotlin version: https://github.com/contentful/vault/blob/master/compiler/src/main/java/com/contentful/vault/compiler/Processor.java#L380

bizon91 commented 6 years ago

Try to add @JvmSuppressWildcards annotation like this @JvmField @Field var content: List<@JvmSuppressWildcards Resource>? = null

kzotin commented 6 years ago

@bizon91 kudos for advice, it helped!

mariobodemann commented 5 years ago

< closing this issue due to inactivity and seemingly finding a solution >