Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Allow nested generic types#129

Open
runningcode wants to merge 2 commits intoJakeWharton:masterfrom
runningcode:no/nested-generic
Open

Allow nested generic types#129
runningcode wants to merge 2 commits intoJakeWharton:masterfrom
runningcode:no/nested-generic

Conversation

@runningcode
Copy link
Contributor

Dont allow type variables in keys.

}
} 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
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.

@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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants