]
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: