-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
There is a strange piece of code in org.jboss.weld.util.reflection.Reflections:
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; }
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.