11

I'm rewriting my model class to Kotlin, which has to be Parcelable and used in AIDL:

@Parcelize
data class MyCustomObject(val value1: String, val value2: String) : Parcelable

During compilation it crashes with error:

error: incompatible types: Object cannot be converted to MyCustomObject

and points to this line in generated code:

if ((0!=_reply.readInt())) {
    _result = com.mypackagename.MyCustomObject.CREATOR.createFromParcel(_reply);
}

I used this annotation for other purposes and it was ok, only in AIDL I found mismatch so far.

Any ideas what's wrong?

EDIT: After 5 days with no single comment I've created a ticket for this issue.

Yurets
  • 3,999
  • 17
  • 54
  • 74

1 Answers1

5

It is a bug in Kotlin, so I redirected this issue to JetBrains. You may track it here: KT-25807.

This happens, because createFromParcel() does not return class T, but Object.

UPD

Parcelize annotation is now maintainable by Google and the issue has been fixed in kotlin version 1.5.+ https://issuetracker.google.com/issues/110131003

Yurets
  • 3,999
  • 17
  • 54
  • 74