I am confused as to what could be wrong with determining that Container<String> is *not* assignable to Container<Integer>. But are you saying that the manually constructed parameterized Type *is* reported as being assignable despite the obviously incompatible type parameters?
Matt On Thu, May 30, 2024, 10:31 AM Sunny Chan <sunny.c...@crypto.com.invalid> wrote: > I have an issue with TypeUtils.isAssignableTo and I would like to check > whether this is expected or a bug. > > Consider we have a number of classes > > class Container<A> {.......} > > class ParameterizedConstructor<String> { > //consturctor that takes a container > public ParameterizedConstructor(Container<String> input) {..} > } > > Then if I use TypeUtils to create some parameterized type for checking > purposes: > > //The following will give you TypeVariable with Container<String> > var constructors = ParameterizedConstructor.class.getConstructors(); > var parameters = constructors[0].getGenericParameterTypes(); > Type assignableTo = parameters[0]; > > // I want to check whether we can do a equals > Type assignFrom = TypeUtils.parameterize(Container.class, Integer.class); > > //If you run this with lang 3 it will return true but I get a false here : > TypeUtils.isAssignable(assignFrom, assignTo) > > Notice that if I use TypeUtils factory to create the parameterize type, it > will return correct behaviour > > I am wondering whether we expect ParameterizedType from JDK is not expected > to work here? > > Thanks >