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

Allow nested generic types #129

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

Conversation

runningcode
Copy link
Contributor

Dont allow type variables in keys.

@@ -86,7 +86,9 @@ static void checkNotPrimitive(Type type) {
"unexpected owner type for " + rawType + ": " + ownerType);
}
} else if (enclosingClass != null) {
throw new IllegalArgumentException("unexpected owner type for " + rawType + ": null");
// TODO ?

This comment was marked as resolved.

Copy link
Owner

Choose a reason for hiding this comment

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

What are the input values?

This comment was marked as resolved.

@runningcode runningcode force-pushed the no/nested-generic branch 2 times, most recently from 52cb004 to 2ae5f7c Compare July 5, 2019 09:00
@@ -75,7 +75,8 @@ private static boolean hasParameterizedTypeVariable(Type parameterType) {
private TypeUtil.ParameterizedTypeImpl findKeyForParameterizedType(
ParameterizedType parameterType) {
Type[] matchingTypes = matchingParameterizedType(parameterType.getActualTypeArguments());
return new TypeUtil.ParameterizedTypeImpl(null, parameterType.getRawType(), matchingTypes);
return new TypeUtil.ParameterizedTypeImpl(
parameterType.getOwnerType(), parameterType.getRawType(), matchingTypes);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JakeWharton i wasn't passing in the owner type here which was causing the exception. it is now resolved.

import org.jetbrains.annotations.Nullable;

@AutoValue
abstract class Key {
static Key of(@Nullable Annotation qualifier, Type type) {
if (containsTypeVariable(type)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JakeWharton I can remove this check if it is causing any second thoughts on merging this PR.
It helps surface unsupported bindings in Dagger Reflect as soon as possible. When a Key which includes <T> instead of a real type, it immediately throws an error.
It has a bit of a runtime cost since it recursively checks the type and its parameters whenever a Key is constructed.

Nelson Osacky added 2 commits August 6, 2019 15:15
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.

2 participants