|
70 | 70 | import java.util.Objects; |
71 | 71 | import java.util.Set; |
72 | 72 |
|
73 | | -import org.scijava.util.FileUtils; |
74 | | - |
75 | 73 | /** |
76 | 74 | * Utility class for working with generic types, fields and methods. |
77 | 75 | * <p> |
|
86 | 84 | * </ul> |
87 | 85 | * |
88 | 86 | * @author Curtis Rueden |
| 87 | + * @author Gabe Selzer |
89 | 88 | */ |
90 | 89 | public final class Types { |
91 | 90 |
|
@@ -791,22 +790,22 @@ public static <T> T enumValue(final String name, final Class<T> dest) { |
791 | 790 | public static ParameterizedType parameterize(final Class<?> rawType, |
792 | 791 | final Type... typeArgs) |
793 | 792 | { |
794 | | - return parameterize(rawType, rawType.getDeclaringClass(), typeArgs); |
| 793 | + return parameterizeWithOwner(null, rawType, typeArgs); |
795 | 794 | } |
796 | 795 |
|
797 | 796 | /** |
798 | 797 | * Creates a new {@link ParameterizedType} of the given class together with |
799 | 798 | * the specified type arguments. |
800 | 799 | * |
801 | | - * @param rawType The class of the {@link ParameterizedType}. |
802 | 800 | * @param ownerType The owner type of the parameterized class. |
| 801 | + * @param rawType The class of the {@link ParameterizedType}. |
803 | 802 | * @param typeArgs The type arguments to use in parameterizing it. |
804 | 803 | * @return The newly created {@link ParameterizedType}. |
805 | 804 | */ |
806 | | - public static ParameterizedType parameterize(final Class<?> rawType, |
807 | | - final Type ownerType, final Type... typeArgs) |
| 805 | + public static ParameterizedType parameterizeWithOwner(final Type ownerType, |
| 806 | + final Class<?> rawType, final Type... typeArgs) |
808 | 807 | { |
809 | | - return new TypeUtils.ParameterizedTypeImpl(rawType, ownerType, typeArgs); |
| 808 | + return TypeUtils.parameterizeWithOwner(ownerType, rawType, typeArgs); |
810 | 809 | } |
811 | 810 |
|
812 | 811 | /** |
@@ -3206,7 +3205,7 @@ else if (isMissingTypeParameters(clazz)) { |
3206 | 3205 | Arrays.fill(arguments, UNBOUND_WILDCARD); |
3207 | 3206 | final Type owner = clazz.getDeclaringClass() == null ? null |
3208 | 3207 | : addWildcardParameters(clazz.getDeclaringClass()); |
3209 | | - return parameterize(clazz, owner, arguments); |
| 3208 | + return parameterizeWithOwner(owner, clazz, arguments); |
3210 | 3209 | } |
3211 | 3210 | else { |
3212 | 3211 | return clazz; |
@@ -3584,9 +3583,9 @@ public static Type capture(final Type type) { |
3584 | 3583 | for (final CaptureTypeImpl captured : toInit) { |
3585 | 3584 | captured.init(varMap); |
3586 | 3585 | } |
3587 | | - final Type ownerType = (pType.getOwnerType() == null) ? null : capture( |
| 3586 | + final Type ownerType = pType.getOwnerType() == null ? null : capture( |
3588 | 3587 | pType.getOwnerType()); |
3589 | | - return parameterize(clazz, ownerType, capturedArguments); |
| 3588 | + return parameterizeWithOwner(ownerType, clazz, capturedArguments); |
3590 | 3589 | } |
3591 | 3590 | return type; |
3592 | 3591 | } |
@@ -3764,9 +3763,10 @@ else if (type instanceof TypeVariable) { |
3764 | 3763 | } |
3765 | 3764 | else if (type instanceof ParameterizedType) { |
3766 | 3765 | final ParameterizedType pType = (ParameterizedType) type; |
3767 | | - return parameterize((Class<?>) pType.getRawType(), pType |
3768 | | - .getOwnerType() == null ? pType.getOwnerType() : map(pType |
3769 | | - .getOwnerType()), map(pType.getActualTypeArguments())); |
| 3766 | + final Type ownerType = pType.getOwnerType() == null ? // |
| 3767 | + pType.getOwnerType() : map(pType.getOwnerType()); |
| 3768 | + return parameterizeWithOwner(ownerType, (Class<?>) pType.getRawType(), |
| 3769 | + map(pType.getActualTypeArguments())); |
3770 | 3770 | } |
3771 | 3771 | else if (type instanceof WildcardType) { |
3772 | 3772 | final WildcardType wType = (WildcardType) type; |
|
0 commit comments