use of javax.lang.model.type.TypeMirror in project buck by facebook.
the class TypeResolverTest method testMultiDimArrayTypeResolves.
@Test
public void testMultiDimArrayTypeResolves() throws IOException {
compile("abstract class Foo extends java.util.ArrayList<java.lang.String[][]> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeElement listElement = elements.getTypeElement("java.util.ArrayList");
TypeMirror stringType = elements.getTypeElement("java.lang.String").asType();
ArrayType stringArrayType = types.getArrayType(stringType);
ArrayType stringArrayArrayType = types.getArrayType(stringArrayType);
DeclaredType expectedSuperclass = types.getDeclaredType(listElement, stringArrayArrayType);
assertSameType(expectedSuperclass, fooElement.getSuperclass());
}
use of javax.lang.model.type.TypeMirror in project buck by facebook.
the class TreeBackedTypeParameterElementTest method testTypeParameterBoundedTypeParameter.
@Test
public void testTypeParameterBoundedTypeParameter() throws IOException {
compile("class Foo<T, U extends T> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeParameterElement uElement = fooElement.getTypeParameters().get(1);
TypeMirror tType = fooElement.getTypeParameters().get(0).asType();
assertSameType(tType, uElement.getBounds().get(0));
}
use of javax.lang.model.type.TypeMirror in project buck by facebook.
the class TreeBackedTypesTest method testIsNotSameTypeStaticNoGenerics.
@Test
public void testIsNotSameTypeStaticNoGenerics() throws IOException {
compile(ImmutableMap.of("Foo.java", "class Foo { }", "Bar.java", "class Bar { }"));
TypeMirror fooType = elements.getTypeElement("Foo").asType();
TypeMirror barType = elements.getTypeElement("Bar").asType();
assertNotSameType(fooType, barType);
}
use of javax.lang.model.type.TypeMirror in project buck by facebook.
the class TreeBackedTypesTest method testIsNotSameTypeParameterizedType.
@Test
public void testIsNotSameTypeParameterizedType() throws IOException {
initCompiler();
TypeElement listElement = elements.getTypeElement("java.util.List");
TypeMirror stringType = elements.getTypeElement("java.lang.String").asType();
TypeMirror integerType = elements.getTypeElement("java.lang.Integer").asType();
TypeMirror listStringType = types.getDeclaredType(listElement, stringType);
TypeMirror listIntType = types.getDeclaredType(listElement, integerType);
assertNotSameType(listStringType, listIntType);
}
use of javax.lang.model.type.TypeMirror in project buck by facebook.
the class TreeBackedTypesTest method testIsSameTypeUnboundedTypeVariable.
@Test
public void testIsSameTypeUnboundedTypeVariable() throws IOException {
compile("class Foo<T> extends java.util.ArrayList<T> { }");
TypeElement fooElement = elements.getTypeElement("Foo");
TypeMirror t1 = fooElement.getTypeParameters().get(0).asType();
TypeMirror t2 = ((DeclaredType) fooElement.getSuperclass()).getTypeArguments().get(0);
assertSameType(t1, t2);
}
Aggregations