-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parceler: Types do not match for property java.util.List<? extends #366
Comments
Hmmm, are you able to show the Java classes Kotlin is generating for |
Here is what I can find in import java.lang.System;
@kotlin.Metadata(...)
public final class ChildZonesParcelConverterTest {
@org.junit.Test()
public final void testChildZonesParcelConverter() {
}
public ChildZonesParcelConverterTest() {
super();
}
@kotlin.Metadata(...)
@org.parceler.Parcel(value = org.parceler.Parcel.Serialization.BEAN)
public static final class ParentZone {
@org.jetbrains.annotations.NotNull()
private final java.lang.String name = null;
@org.jetbrains.annotations.NotNull()
private java.util.List<? extends com.example.models.ChildZone> childZones;
@org.jetbrains.annotations.NotNull()
public final java.lang.String getName() {
return null;
}
@org.jetbrains.annotations.NotNull()
public final java.util.List<com.example.models.ChildZone> getChildZones() {
return null;
}
public final void setChildZones(@org.jetbrains.annotations.NotNull()
java.util.List<? extends com.example.models.ChildZone> p0) {
}
@org.parceler.ParcelConstructor()
public ParentZone(@org.jetbrains.annotations.NotNull() java.lang.String name,
@org.jetbrains.annotations.NotNull()
@org.parceler.ParcelPropertyConverter(value = com.example.models.ChildZonesParcelConverter.class)
java.util.List<? extends com.example.models.ChildZone> childZones) {
super();
}
@org.jetbrains.annotations.NotNull()
public final java.lang.String component1() {
return null;
}
@org.jetbrains.annotations.NotNull()
public final java.util.List<com.example.models.ChildZone> component2() {
return null;
}
@org.jetbrains.annotations.NotNull()
public final com.example.models.ChildZonesParcelConverterTest.ParentZone copy(
@org.jetbrains.annotations.NotNull()
java.lang.String name,
@org.jetbrains.annotations.NotNull()
@org.parceler.ParcelPropertyConverter(value = com.example.models.ChildZonesParcelConverter.class)
java.util.List<? extends com.example.models.ChildZone> childZones) {
return null;
}
@org.jetbrains.annotations.NotNull()
@java.lang.Override()
public java.lang.String toString() {
return null;
}
@java.lang.Override()
public int hashCode() {
return 0;
}
@java.lang.Override()
public boolean equals(@org.jetbrains.annotations.Nullable()
java.lang.Object p0) {
return false;
}
}
} |
Ah, that's perfect @johnjohndoe, thanks! I need to think on this a bit... |
Here's a failing unit test to work off of, if you want to get your hands dirty @johnjohndoe: Add this to @Parcel(Serialization.BEAN)
static class GenericMixedExtends {
private List<String> values;
public List<String> getValues() {
return values;
}
public void setValues(List<? extends String> values) {
this.values = new ArrayList<String>();
this.values.addAll(values);
}
}
@Test
public void testMixedGenericExtends() {
ParcelableDescriptor analysis = analyze(GenericMixedExtends.class);
assertFalse(messager.getMessage(), messager.isErrored()); // Fails here
assertNull(analysis.getParcelConverterType());
assertNotNull(analysis.getConstructorPair());
assertEquals(0, analysis.getFieldPairs().size());
assertEquals(1, analysis.getMethodPairs().size());
assertEquals(0, analysis.getConstructorPair().getWriteReferences().size());
assertEquals(0, analysis.getWrapCallbacks().size());
assertEquals(0, analysis.getUnwrapCallbacks().size());
} changing The indicated line fails with: |
Thank you for pointing into the source code! However, I stepped away from using Kotlin data classes at the moment. The reason is that this would require me to add the jackson-module-kotlin library to the dependencies of my project which itself depends on kotlin-reflect. The latter is known for increasing the size of the final APK. I am trying to avoid this. Therefore, I will not work on the topic in the near future. |
Fair enough. I do appreciate this issue @johnjohndoe. Let me know if you need anything else. |
I am trying to convert the following working JUnit test from Java ...
... to Kotlin.
The relationship between
ChildZone
andLowEmissionZone
is as follows:Executing the Kotlin test fails with the following error:
Related
The text was updated successfully, but these errors were encountered: