Open rizzz87 opened 9 years ago
This is a limitation of this library. I've made an assumption that every class parcels its own fields. If there was no such assumption, having a proper and intuitive implementation for your case would most likely be impossible to achieve. Let me give you an example how far can this go based on your code:
Parcelable
, so
It's just a simple analysis of the problem and we could probably find a few more decisions to be made. There is also no single solution that would be ok for all developers.
It's unlikely you are the only person having this requirement for your code (I've heard from one more person about this), but I'd want the code to be explicit about what it does. In your case you most likely want to use getters and setters to parcel fields from base class.
Thanks for the explanation! Do you have plan to investigate this issue and prepare some solution (if possible) ? Or this issue should be just closed as 'Won't fix' because of the mentioned limitations ? Thanks in advance.
I don't think there is a single working solution for all use cases.
Actually someone has asked similar thing on Hrisey's Gitter a few months ago about extending abstract classes.
If you want to start discussion on how this could be solved with code generation, I'd suggest adding a few (failing) test cases. This is a very simple operation. Just adding two files with two classes: one with annotation and the other with generated code. Take a look at ParcelableInt before and after applying transformation.
And I have just found that I even added Parcelable extending non-parcelable (it's ignored tho), which might be a good template for you to state with tests what should happen.
I'm trying to use @Parcelable annotation from Hrisey library for parcelable class which should (for various reasons) extend POJO class directly (It can't be parcelable itself and I don't want to use abstract classes in the middle. It has to be direct inheritance). The thing which I want to achieve is:
and the second class:
The problem is that when I'm trying to build (gradlew clean build) this code with gradle I've following error:
Additionally, I've done also build execution with --stacktrace flag and the output is (only exception):
Maybe it is a limitation of this library or annotation processing but based the documentation examples it looks like such inheritance should be possible. Anyway, I don't think that it is such rarely situation to try to inherit from POJO class. I think that it will require some investigation. Thanks!