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 isGenerified to work with anonymous subclasses using the enclosing methods type parameter #1271

Merged
merged 1 commit into from Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -88,6 +88,7 @@ public interface TypeVariableSource extends ModifierReviewable.OfAbstraction {
* <ul>
* <li>A type declares type variables or is an inner class of a type with a generic declaration.</li>
* <li>A method declares at least one type variable.</li>
* <li>A type is an inner anonymous class of a method with a generic declaration</li>
* </ul>
*
* @return {@code true} if this type code element has a generic declaration.
Expand Down
Expand Up @@ -8060,7 +8060,11 @@ public boolean isGenerified() {
return false;
}
TypeDescription declaringType = getDeclaringType();
return declaringType != null && declaringType.isGenerified();
if (declaringType != null && declaringType.isGenerified()) {
return true;
}
MethodDescription.InDefinedShape enclosingMethod = getEnclosingMethod();
return enclosingMethod != null && enclosingMethod.isGenerified();
}

/**
Expand Down
Expand Up @@ -666,6 +666,7 @@ public void testIsGenerified() throws Exception {
assertThat(describe(GenericSample.Nested.class).isGenerified(), is(false));
assertThat(describe(GenericSample.NestedInterface.class).isGenerified(), is(false));
assertThat(describe(Object.class).isGenerified(), is(false));
assertThat(describe(getAnonymousGenericSample().getClass()).isGenerified(), is(true));
}

@Test
Expand Down Expand Up @@ -1034,6 +1035,12 @@ interface NestedInterface {
}
}

private <T> GenericSample<T> getAnonymousGenericSample() {
return new GenericSample<T>() {
/* empty */
};
}

private static class Type$With$Dollar {
/* */
}
Expand Down