Skip to content

Commit

Permalink
#136 Resolve bounded wildcard types
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Mar 9, 2016
1 parent 1f184f6 commit 79e106c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ private static TypeTag resolve(Type type, TypeTag enclosingType) {
return new TypeTag(arrayType, tag.getGenericTypes());
}
if (type instanceof WildcardType) {
return new TypeTag(Wildcard.class);
WildcardType wt = (WildcardType)type;
for (Type b : wt.getLowerBounds()) {
return resolve(b, enclosingType);
}
for (Type b : wt.getUpperBounds()) {
return resolve(b, enclosingType);
}
return new TypeTag(Object.class);
}
if (type instanceof java.lang.reflect.TypeVariable) {
Map<String, TypeTag> typeVariableLookup = buildLookup(enclosingType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nl.jqno.equalsverifier.internal.prefabvalues;

import nl.jqno.equalsverifier.testhelpers.types.Point;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -40,6 +41,8 @@ public class TypeTagParameterizedTest<T> {
@SuppressWarnings("unused") private final List<?> fieldWithWildcardParameter = null;
@SuppressWarnings("unused") private final Class<String>[] fieldWithGenericArrayParameter = null;
@SuppressWarnings("unused") private final List<T> fieldWithTypeVariable = null;
@SuppressWarnings("unused") private final List<? extends Comparable<T>> fieldWithExtendingTypeVariable = null;
@SuppressWarnings("unused") private final List<? super Point> fieldWithSuperingTypeVariable = null;

@SuppressWarnings("unused") private final int primitiveField = 0;
@SuppressWarnings("unused") private final String[] arrayField = null;
Expand Down Expand Up @@ -69,9 +72,11 @@ public static Collection<Object[]> data() {
new TypeTag(String.class),
new TypeTag(Float.class)))) },
{ "rawMapField", new TypeTag(Map.class) },
{ "fieldWithWildcardParameter", new TypeTag(List.class, new TypeTag(TypeTag.Wildcard.class)) },
{ "fieldWithWildcardParameter", new TypeTag(List.class, new TypeTag(Object.class)) },
{ "fieldWithGenericArrayParameter", new TypeTag(Class[].class, new TypeTag(String.class)) },
{ "fieldWithTypeVariable", new TypeTag(List.class, new TypeTag(TypeTag.TypeVariable.class)) },
{ "fieldWithExtendingTypeVariable", new TypeTag(List.class, new TypeTag(Comparable.class, new TypeTag(Object.class))) },
{ "fieldWithSuperingTypeVariable", new TypeTag(List.class, new TypeTag(Point.class)) },
{ "primitiveField", new TypeTag(int.class) },
{ "arrayField", new TypeTag(String[].class) }
});
Expand Down

0 comments on commit 79e106c

Please sign in to comment.