johncarl81 / parceler

:package: Android Parcelables made easy through code generation.
http://parceler.org
Apache License 2.0
3.56k stars 273 forks source link

Parceler: Unable to find read/write generator for type java.util.List<EnumType> #368

Open bkolarov opened 5 years ago

bkolarov commented 5 years ago

Hello, Parceler produces a compile time error when I use it on a Kotlin data class, that accepts an immutable list of enum values. Here is the concrete example:

@Parcel(Parcel.Serialization.BEAN)
data class FeaturesResponse @ParcelConstructor constructor(var features: List<FeatureResponse>)

enum class FeatureResponse {
    FEATURE_1, FEATURE_2,
    UNKNOWN
}

And here is the error I get:

: Parceler: Unable to find read/write generator for type java.util.List<? extends FeatureResponse> for java.util.List<? extends FeatureResponse> features java.util.List<? extends FeatureResponse> features) {
                                                                                                       ^
e: /EnabledFeaturesResponse.java:12: error: Parceler: Types do not match for property features java.util.List<? extends FeatureResponse> java.util.List<FeatureResponse> public final java.util.List<FeatureResponse> getFeatures() {                                                                                                      ^

I think a possible workaround is to replace List With MutableList as the error doesn't appear then, but the issue remains.

johncarl81 commented 5 years ago

This was reported recently here: https://github.com/johncarl81/parceler/issues/366. I have a reproducible failing test case if you want to try your hand at a fix PR.