Search in sources :

Example 1 with Banana

use of spoon.test.generics.testclasses.Banana in project spoon by INRIA.

the class GenericsTest method testClassContextOnInnerClass.

@Test
public void testClassContextOnInnerClass() throws Exception {
    CtClass<?> classBanana = (CtClass<?>) buildClass(Banana.class);
    CtClass<?> classVitamins = classBanana.getNestedType("Vitamins");
    CtTypeReference<?> refList_T = classVitamins.getSuperclass();
    // contract: generic types defined in enclocing classe (Banana<T>) are resolved from inner class hierarchy (Vitamins->List<T>) too.
    assertSame(classBanana.getFormalCtTypeParameters().get(0), new ClassTypingContext(classVitamins).adaptType(refList_T.getActualTypeArguments().get(0)).getDeclaration());
}
Also used : LikeCtClass(spoon.test.generics.testclasses2.LikeCtClass) CtClass(spoon.reflect.declaration.CtClass) ClassTypingContext(spoon.support.visitor.ClassTypingContext) Banana(spoon.test.generics.testclasses.Banana) MainTest(spoon.test.main.MainTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CtClass (spoon.reflect.declaration.CtClass)1 ClassTypingContext (spoon.support.visitor.ClassTypingContext)1 Banana (spoon.test.generics.testclasses.Banana)1 LikeCtClass (spoon.test.generics.testclasses2.LikeCtClass)1 MainTest (spoon.test.main.MainTest)1