TypeUtilsTest contains incorrect type assignability assertion due to
lost/skipped type variable information during the decision process
---------------------------------------------------------------------------------------------------------------------------------------
Key: LANG-776
URL: https://issues.apache.org/jira/browse/LANG-776
Project: Commons Lang
Issue Type: Bug
Components: lang.reflect.*
Affects Versions: 3.1
Reporter: Matt Benson
Assignee: Matt Benson
{{TypeUtilsTest}} originally contained the following under
#{{testIsAssignable()}}:
{code}
Assert.assertTrue("WRONG!", TypeUtils.isAssignable(dingType, disType));
{code}
For background:
{code}
public interface This<K, V> {
}
public class Other<T> implements This<String, T> {
}
public class Thing<Q> extends Other<B> {
}
{code}
{{<B>}} refers to a type parameter on the {{TypeUtilsTest}} class itself.
{{disType}} and {{dingType}} refer to the generic types of the following
fields, respectively:
{code}
public This<String, String> dis;
public Thing ding;
{code}
Thus the assertion in question declares that type {{Thing}} is assignable to
{{This<String, String>}}. If we start at {{This}} we can see that the
implementing class {{Other}} maps its {{T}} type parameter to the {{V}} type
parameter of {{This}}. From this point we can proceed down to {{Thing}} and
see that it maps the {{B}} type parameter of the enclosing {{TypeUtilsTest}}
class to the {{T}} type parameter of {{Other}}. Thus it is fairly obvious that
only a {{TypeUtilsTest<String>.Thing}} is assignable to {{This<String,
String>}}. From this we can determine that the intent of the message in the
original test assertion must indeed have been to flag an incorrect assertion.
This is the associated bug report.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira