Skip to content
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

Fix ArgsBundler return type #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix ArgsBundler return type #67

wants to merge 2 commits into from

Conversation

vganin
Copy link

@vganin vganin commented Jul 15, 2016

This should close #53

@@ -15,7 +15,7 @@
bundle.putParcelable(key, Parcels.wrap(value));
}

@Override public <V> V get(String key, Bundle bundle) {
@Override public Object get(String key, Bundle bundle) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this is working properly? I mean, if we return here Object somewhere has to be a cast to the real class, right? By using generic methods <V> the compiler can determine what the actual return type is because Parcels.unwrap() knows <V> too.

Copy link
Author

@vganin vganin Jul 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I've assembled test project and I see the problem now. I've updated the PR.

My proposition is to remove inferred return type from interface and add strict casting to generated code. Pros are obvious but there is one caveat. User can specify the inheritor of arg class and try to use the bundler for its super class. In this case we get ClassCastException in run time instead of compile time error. Although I don't think somebody will do something like that (only mistakenely maybe).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning when implementing ArgsBundler
2 participants