Merge branch 'bug/LANG-1114-TypeUtils.Wildcard.equals.bug'

LANG-1114: TypeUtils.ParameterizedType#equals doesn't work with wildcard types.
This closes #73 from github. Thanks to Andy Coates.
This commit is contained in:
Benedikt Ritter 2015-04-29 19:47:09 +02:00
commit 640953167a
3 changed files with 13 additions and 1 deletions

View File

@ -22,6 +22,7 @@
<body>
<release version="3.5" date="tba" description="tba">
<action issue="LANG-1114" type="fix" dev="britter" due-to="Andy Coates">TypeUtils.ParameterizedType#equals doesn't work with wildcard types</action>
<action issue="LANG-1119" type="add" dev="britter" due-to="Loic Guibert">Add rotate(string, int) method to StringUtils</action>
<action issue="LANG-1118" type="fix" dev="britter" due-to="Loic Guibert">StringUtils.repeat('z', -1) throws NegativeArraySizeException</action>
<action issue="LANG-1099" type="add" dev="britter" due-to="Adrian Ber">Add swap and shift operations for arrays to ArrayUtils</action>

View File

@ -1626,7 +1626,7 @@ public class TypeUtils {
return equals(getImplicitLowerBounds(w), getImplicitLowerBounds(other))
&& equals(getImplicitUpperBounds(w), getImplicitUpperBounds(other));
}
return true;
return false;
}
/**

View File

@ -97,6 +97,8 @@ public class TypeUtilsTest<B> {
public static Comparable<Long> longComparable;
public static Comparable<?> wildcardComparable;
public static URI uri;
public void dummyMethod(final List list0, final List<Object> list1, final List<?> list2,
@ -722,6 +724,15 @@ public class TypeUtilsTest<B> {
Assert.assertEquals(String.format("? super %s", iterableT0.getName()), lowerTypeVariable.toString());
}
@Test
public void testLang1114() throws Exception {
final Type nonWildcardType = getClass().getDeclaredField("wildcardComparable").getGenericType();
final Type wildcardType = ((ParameterizedType)nonWildcardType).getActualTypeArguments()[0];
Assert.assertFalse(TypeUtils.equals(wildcardType, nonWildcardType));
Assert.assertFalse(TypeUtils.equals(nonWildcardType, wildcardType));
}
@Test
public void testGenericArrayType() throws Exception {
final Type expected = getClass().getField("intWildcardComparable").getGenericType();