[weld-issues] [JBoss JIRA] (WELD-1102) Bean type Foo<B extends Bar> not assignable to required type Foo<Bar<Integer>>
Ales Justin (JIRA)
jira-events at lists.jboss.org
Wed Apr 11 05:03:47 EDT 2012
[ https://issues.jboss.org/browse/WELD-1102?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ales Justin resolved WELD-1102.
-------------------------------
Fix Version/s: 1.1.7.Final
Resolution: Done
> Bean type Foo<B extends Bar> not assignable to required type Foo<Bar<Integer>>
> ------------------------------------------------------------------------------
>
> Key: WELD-1102
> URL: https://issues.jboss.org/browse/WELD-1102
> Project: Weld
> Issue Type: Bug
> Reporter: Marko Lukša
> Assignee: Marko Lukša
> Fix For: 1.1.7.Final
>
>
> There is a strange piece of code in {{org.jboss.weld.util.reflection.Reflections}}:
> {code}
> public static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Type type2) {
> ...
> } else if (type2 instanceof TypeVariable<?>) {
> TypeVariable<?> typeVariable = (TypeVariable<?>) type2;
> if (isTypeBounded(rawType1, actualTypeArguments1, typeVariable.getBounds())) { <--- suspicious!
> return true;
> }
> }
> ...
> }
> public static boolean isTypeBounded(Type type, Type[] lowerBounds, Type[] upperBounds) {
> if (lowerBounds.length > 0) {
> if (!isAssignableFrom(type, lowerBounds)) {
> return false;
> }
> }
> if (upperBounds.length > 0) {
> if (!isAssignableFrom(upperBounds, type)) {
> return false;
> }
> }
> return true;
> }
> {code}
> What's strange is that {{isTypeBounded()}} is called with actualTypeArguments1, which are actual type arguments of type1 (and not type2!).
> The result is that the bean type {{Foo<B extends Bar>}} is assignable to {{Foo<Bar<Baz>>}} (if Baz extends Bar), but it is NOT assignable to {{Foo<Bar<Integer>>}} just because Bar is not assignable from Integer.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the weld-issues
mailing list