-
Notifications
You must be signed in to change notification settings - Fork 103
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
Problem with Generics and AdapterFactory #79
Comments
Just documenting for clarity after taking a peek, the issue is in the generated factory itself, not in the actual class definition. public final class AutoValueGson_SampleAdapterFactory extends SampleAdapterFactory {
@Override
@SuppressWarnings("unchecked")
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
Class<?> rawType = type.getRawType();
if (Foo.class.isAssignableFrom(rawType)) {
return (TypeAdapter<T>) Foo.typeAdapter(gson, (TypeToken<? extends Foo<A, B, C>>) type);
} else {
return null;
}
}
} |
ZacSweers
added a commit
that referenced
this issue
Jan 13, 2019
…handling Resolves #79 and simplifies the way generics are handled. Before this we were always going through and trying to pass around or unpack a typetoken and mess with the generics, only to raw them out to `Type` under the hood anyway. This basically matches how we do it in `auto-value-moshi` and switches to just accept that `Type[]` directly and also handle that in the generated factory.
ZacSweers
added a commit
that referenced
this issue
Jan 13, 2019
…handling (#193) Simplifies the way generics are handled. Before this we were always going through and trying to pass around or unpack a typetoken and mess with the generics, only to raw them out to `Type` under the hood anyway. This basically matches how we do it in `auto-value-moshi` and switches to just accept that `Type[]` directly and also handle that in the generated factory. Resolves #79 Resolves #115
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I add the example with generics to my code:
I have this error on my
AdapterFactory
:To fix it I must change
TypeToken<? extends Foo<A, B, C>> typeToken
toTypeToken<? extends Foo> typeToken
:What's the problem? The example? Am I missing anything? Is my "fix" correct?
The text was updated successfully, but these errors were encountered: