Status Update
Comments
ca...@gmail.com <ca...@gmail.com> #2
And as far i can tell, this is happening because createFromParcel in generated code returns Object instead original Class
e....@gmail.com <e....@gmail.com> #3
This is not Android issue. Kotlin is responsible for generating the Parcelable implementation.
Report this in Kotlin issue tracker:
es...@google.com <es...@google.com>
dw...@google.com <dw...@google.com>
dw...@google.com <dw...@google.com>
ag...@google.com <ag...@google.com>
sa...@gmail.com <sa...@gmail.com> #6
st...@google.com <st...@google.com> #7
Just checked that this is fixed in Kotlin 1.5.10 and the code probably also worked in several earlier versions.
For some background, this was an issue with the old JVM backend, which was fixed Robert Bares
sa...@gmail.com <sa...@gmail.com> #8
ak...@gmail.com <ak...@gmail.com> #9
xi...@gmail.com <xi...@gmail.com> #10
This issus is still exists in the Kotlin version 1.7.10
ag...@google.com <ag...@google.com>
st...@google.com <st...@google.com> #11
I cannot reproduce the issue with Kotlin 1.7.10.
One inconsistency that I noticed is that Android Studio displays an error on createFromParcel
calls in the java files generated from AIDL. This seems to be purely cosmetic, since the generated code contains the correct generic types, both with the old and current Kotlin compiler backend.
Is this the issue that you're seeing or do you have a project that fails to compile? If so, would it be possible to share a reproduction?
st...@google.com <st...@google.com> #12
Here's what's going on with the error that the Java editor displays on the AIDL generated files:
IntelliJ has a way of resolving usages of Kotlin classes in Java code without compiling the code first, called UltraLightClasses
. The Parcelize plugin ships an extension to UltraLightClasses
with the Kotlin plugin in IntelliJ (!) and this code has CREATOR
fieldCREATOR
field has the raw type Parcelable.Creator
and hence that createFromParcel
returns results of type Object
. Meanwhile the compiled code contains the correct generic types and in particular the Java compiler sees the correct types.
In summary, this is a purely cosmetic problem, the actual code is correct and it is only the editor display in the IDE that's broken.
I'm going to fix this, but please speak up if you encounter any issue that is not cosmetic and results in build or runtime errors, because that would be a different issue.
Description
during compilation when changed POJO to Kotlin data class with @Parcelize annotation.
and points to generated code's line:
if ((0!=_reply.readInt())) {
_result = com.mypackagename.MyCustomObject.CREATOR.createFromParcel(_reply);
}
Asked question on stackoverflow, no result after 5 days. In other cases @Parcelize works fine. Also, there seems to be no workaround so far: