Handle case when upper bound of WildcardType is TypeVariable

When creating list of objects with generics, upper bound is of type TypeVariable. This causes a CastException in the existing code. This patch adds new unit test to test this condition and a fix for it.