Search in sources :

Example 1 with TypeVariable

use of javax.lang.model.type.TypeVariable in project buck by facebook.

the class StandaloneTypeVariableTest method testGetLowerBoundMultipleBounds.

@Test
public void testGetLowerBoundMultipleBounds() throws IOException {
    compile("class Foo<T extends java.lang.Runnable & java.lang.CharSequence> { }");
    TypeVariable tVar = (TypeVariable) elements.getTypeElement("Foo").getTypeParameters().get(0).asType();
    assertSameType(types.getNullType(), tVar.getLowerBound());
}
Also used : TypeVariable(javax.lang.model.type.TypeVariable) Test(org.junit.Test)

Example 2 with TypeVariable

use of javax.lang.model.type.TypeVariable in project buck by facebook.

the class StandaloneTypeVariableTest method testToStringMultipleBounds.

@Test
public void testToStringMultipleBounds() throws IOException {
    compile("class Foo<T extends java.lang.CharSequence & java.lang.Runnable> { }");
    TypeVariable typeVariable = (TypeVariable) elements.getTypeElement("Foo").getTypeParameters().get(0).asType();
    assertEquals("T", typeVariable.toString());
}
Also used : TypeVariable(javax.lang.model.type.TypeVariable) Test(org.junit.Test)

Example 3 with TypeVariable

use of javax.lang.model.type.TypeVariable in project buck by facebook.

the class StandaloneTypeVariableTest method testToStringUnbounded.

@Test
public void testToStringUnbounded() throws IOException {
    compile("class Foo<T> { }");
    TypeVariable typeVariable = (TypeVariable) elements.getTypeElement("Foo").getTypeParameters().get(0).asType();
    assertEquals("T", typeVariable.toString());
}
Also used : TypeVariable(javax.lang.model.type.TypeVariable) Test(org.junit.Test)

Example 4 with TypeVariable

use of javax.lang.model.type.TypeVariable in project buck by facebook.

the class StandaloneTypeVariableTest method testGetLowerBoundUnbounded.

@Test
public void testGetLowerBoundUnbounded() throws IOException {
    compile("class Foo<T> { }");
    TypeVariable tVar = (TypeVariable) elements.getTypeElement("Foo").getTypeParameters().get(0).asType();
    assertSameType(types.getNullType(), tVar.getLowerBound());
}
Also used : TypeVariable(javax.lang.model.type.TypeVariable) Test(org.junit.Test)

Example 5 with TypeVariable

use of javax.lang.model.type.TypeVariable in project buck by facebook.

the class StandaloneTypeVariableTest method testToStringBounded.

@Test
public void testToStringBounded() throws IOException {
    compile("class Foo<T extends java.lang.CharSequence> { }");
    TypeVariable typeVariable = (TypeVariable) elements.getTypeElement("Foo").getTypeParameters().get(0).asType();
    assertEquals("T", typeVariable.toString());
}
Also used : TypeVariable(javax.lang.model.type.TypeVariable) Test(org.junit.Test)

Aggregations

TypeVariable (javax.lang.model.type.TypeVariable)80 AnnotatedTypeVariable (org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedTypeVariable)38 TypeMirror (javax.lang.model.type.TypeMirror)30 AnnotatedTypeMirror (org.checkerframework.framework.type.AnnotatedTypeMirror)22 TypeElement (javax.lang.model.element.TypeElement)21 ArrayList (java.util.ArrayList)16 DeclaredType (javax.lang.model.type.DeclaredType)15 HashMap (java.util.HashMap)14 LinkedHashMap (java.util.LinkedHashMap)13 Map (java.util.Map)13 ExecutableElement (javax.lang.model.element.ExecutableElement)12 TypeParameterElement (javax.lang.model.element.TypeParameterElement)12 Test (org.junit.Test)10 ArrayType (javax.lang.model.type.ArrayType)9 WildcardType (javax.lang.model.type.WildcardType)9 AnnotationMirror (javax.lang.model.element.AnnotationMirror)8 Element (javax.lang.model.element.Element)8 AnnotationMirrorMap (org.checkerframework.framework.util.AnnotationMirrorMap)8 AnnotationMirrorSet (org.checkerframework.framework.util.AnnotationMirrorSet)8 VariableElement (javax.lang.model.element.VariableElement)7