MCPcopy Create free account
hub / github.com/antlr/codebuff / getArraySupertype

Method getArraySupertype

output/java_guava/1.4.19/TypeToken.java:1139–1152  ·  view source on GitHub ↗
(Class<? super T> supertype)

Source from the content-addressed store, hash-verified

1137
1138
1139 private TypeToken<? super T> getArraySupertype(Class<? super T> supertype) {
1140 // with component type, we have lost generic type information
1141 // Use raw type so that compiler allows us to call getSupertype()
1142 @SuppressWarnings("rawtypes")
1143 TypeToken componentType = checkNotNull(getComponentType(), "%s isn't a super type of %s", supertype, this);
1144 // array is covariant. component type is super type, so is the array type.
1145 @SuppressWarnings("unchecked") // going from raw type back to generics
1146 TypeToken<?> componentSupertype = componentType.getSupertype(supertype.getComponentType());
1147 @SuppressWarnings("unchecked") // component type is super type, so is array type.
1148 TypeToken<? super T> result = (TypeToken<? super T>)
1149 // If we are passed with int[].class, don't turn it to GenericArrayType
1150of(newArrayClassOrGenericArrayType(componentSupertype.runtimeType));
1151 return result;
1152 }
1153
1154
1155 private TypeToken<? extends T> getArraySubtype(Class<?> subclass) {

Callers 1

getSupertypeMethod · 0.95

Calls 5

getComponentTypeMethod · 0.95
getSupertypeMethod · 0.95
ofMethod · 0.95
checkNotNullMethod · 0.45

Tested by

no test coverage detected