コード例 #1
0
  public void test_isMoreSpecificThan_typeArguments_object() {
    TypeParameterElementImpl element = new TypeParameterElementImpl(identifier("E"));
    TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);

    // E << Object
    assertTrue(type.isMoreSpecificThan(getObject().getType()));
  }
コード例 #2
0
  public void test_isMoreSpecificThan_typeArguments_self() {
    TypeParameterElementImpl element = new TypeParameterElementImpl(identifier("E"));
    TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);

    // E << E
    assertTrue(type.isMoreSpecificThan(type));
  }
コード例 #3
0
  public void test_isMoreSpecificThan_typeArguments_dynamic() {
    TypeParameterElementImpl element = new TypeParameterElementImpl(identifier("E"));
    TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);

    // E << dynamic
    assertTrue(type.isMoreSpecificThan(DynamicTypeImpl.getInstance()));
  }
コード例 #4
0
 public void test_substitute_equal() {
   TypeParameterElementImpl element = new TypeParameterElementImpl(identifier("E"));
   TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
   InterfaceTypeImpl argument = new InterfaceTypeImpl(new ClassElementImpl(identifier("A")));
   TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element);
   assertSame(argument, type.substitute(new Type[] {argument}, new Type[] {parameter}));
 }
コード例 #5
0
  public void test_isMoreSpecificThan_typeArguments_upperBound() {
    ClassElementImpl classS = classElement("A");

    TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(identifier("T"));
    typeParameterT.setBound(classS.getType());
    TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typeParameterT);

    // <T extends S>
    // T << S
    assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.getType()));
  }
コード例 #6
0
  public void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() {
    ClassElementImpl classS = classElement("A");

    TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl(identifier("U"));
    typeParameterU.setBound(classS.getType());
    TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typeParameterU);

    TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(identifier("T"));
    typeParameterT.setBound(typeParameterTypeU);
    TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typeParameterT);

    // <T extends U> and <U extends S>
    // T << S
    assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.getType()));
  }
コード例 #7
0
  public void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() {
    //  class A {}
    //  class B extends A {}
    //
    ClassElement classA = classElement("A");
    ClassElement classB = classElement("B", classA.getType());
    InterfaceType typeA = classA.getType();
    InterfaceType typeB = classB.getType();

    TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(identifier("T"));
    typeParameterT.setBound(typeB);
    TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typeParameterT);

    // <T extends B>
    // T << A
    assertTrue(typeParameterTypeT.isMoreSpecificThan(typeA));
  }
コード例 #8
0
 public void test_getElement() {
   TypeParameterElementImpl element = new TypeParameterElementImpl(identifier("E"));
   TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
   assertEquals(element, type.getElement());
 }