Skip to content

Commit

Permalink
restore the resolveGenericRef with Class
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <[email protected]>
  • Loading branch information
lachlan-roberts committed Feb 1, 2023
1 parent 4933ba9 commit c9004ee
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,41 @@ public static boolean isDefaultConstructable(Class<?> clazz)
}
}

private static boolean resolveGenericRef(GenericRef ref, Class<?> clazz, Type type)
{
if (type instanceof Class)
{
if (type == ref.ifaceClass)
{
// is this a straight ref or a TypeVariable?
ref.setGenericFromType(type, 0);
return true;
}
else
{
// Keep digging
return resolveGenericRef(ref, type);
}
}

if (type instanceof ParameterizedType ptype)
{
Type rawType = ptype.getRawType();
if (rawType == ref.ifaceClass)
{
// Always get the raw type parameter, let unwrap() solve for what it is
ref.setGenericFromType(ptype.getActualTypeArguments()[0], 0);
return true;
}
else
{
// Keep digging
return resolveGenericRef(ref, rawType);
}
}
return false;
}

private static boolean resolveGenericRef(GenericRef ref, Type type)
{
if ((type == null) || (type == Object.class))
Expand All @@ -221,7 +256,7 @@ private static boolean resolveGenericRef(GenericRef ref, Type type)
Type[] ifaces = clazz.getGenericInterfaces();
for (Type iface : ifaces)
{
if (resolveGenericRef(ref, iface))
if (resolveGenericRef(ref, clazz, iface))
{
if (ref.needsUnwrap())
{
Expand Down

0 comments on commit c9004ee

Please sign in to comment.