use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.BoundOrConstraint in project pmd by pmd.
the class TypeInferenceTest method testEqualityReduceNotPrimitiveVsVariable.
@Test
public void testEqualityReduceNotPrimitiveVsVariable() {
// Otherwise, if T is an inference variable, α, and S is not a primitive type, the constraint reduces
// to the bound S = α.
List<BoundOrConstraint> result = new Constraint(number, alpha, EQUALITY).reduce();
assertEquals(1, result.size());
testBoundOrConstraint(result.get(0), number, alpha, EQUALITY, Bound.class);
result = new Constraint(alpha, beta, EQUALITY).reduce();
assertEquals(1, result.size());
testBoundOrConstraint(result.get(0), alpha, beta, EQUALITY, Bound.class);
}
use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.BoundOrConstraint in project pmd by pmd.
the class TypeInferenceTest method testSubtypeReduceProperVsProper.
@Test
public void testSubtypeReduceProperVsProper() {
// A constraint formula of the form ‹S <: T› is reduced as follows:
// If S and T are proper types, the constraint reduces to true if S is a subtype of T (§4.10),
// and false otherwise.
List<BoundOrConstraint> result = new Constraint(integer, number, SUBTYPE).reduce();
assertEquals(0, result.size());
result = new Constraint(number, integer, SUBTYPE).reduce();
assertNull(result);
// Otherwise, if S is the null type, the constraint reduces to true. TODO
// Otherwise, if T is the null type, the constraint reduces to false. TODO
}
use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.BoundOrConstraint in project pmd by pmd.
the class TypeInferenceTest method testLooseInvocationRightBoxing.
@Test
public void testLooseInvocationRightBoxing() {
// Otherwise, if T is a primitive type, let T' be the result of applying boxing conversion (§5.1.7) to T.
// Then the constraint reduces to ‹S = T'›.
List<BoundOrConstraint> result = new Constraint(number, primitiveInt, LOOSE_INVOCATION).reduce();
assertEquals(1, result.size());
testBoundOrConstraint(result.get(0), number, integer, EQUALITY, Constraint.class);
// Otherwise, if T is a parameterized type of the form G<T1, ..., Tn>, and there exists no type of the
// form G<...> that is a supertype of S, but the raw type G is a supertype of S, then the constraint
// reduces to true. TODO
// Otherwise, if T is an array type of the form G<T1, ..., Tn>[]k, and there exists no type of the form
// G<...>[]k that is a supertype of S, but the raw type G[]k is a supertype of S, then the constraint
// reduces to true. (The notation []k indicates an array type of k dimensions.) TODO
}
use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.BoundOrConstraint in project pmd by pmd.
the class TypeInferenceTest method testLooseInvocationProperVsProper.
@Test
public void testLooseInvocationProperVsProper() {
// A constraint formula of the form ‹S → T› is reduced as follows:
// If S and T are proper types, the constraint reduces to true if S is compatible in a loose invocation
// context with T (§5.3), and false otherwise.
List<BoundOrConstraint> result = new Constraint(number, integer, LOOSE_INVOCATION).reduce();
assertNull(result);
result = new Constraint(integer, number, LOOSE_INVOCATION).reduce();
assertEquals(0, result.size());
}
use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.BoundOrConstraint in project pmd by pmd.
the class TypeInferenceTest method testEqualityReduceSameErasure.
@Test
public void testEqualityReduceSameErasure() {
// Otherwise, if S and T are class or interface types with the same erasure, where S has type
// arguments B1, ..., Bn and T has type arguments A1, ..., An, the constraint reduces to the
// following new constraints: for all i (1 ≤ i ≤ n), ‹Bi = Ai›.
List<BoundOrConstraint> result = new Constraint(generic, generic, EQUALITY).reduce();
assertEquals(2, result.size());
testBoundOrConstraint(result.get(0), number, number, EQUALITY, Constraint.class);
testBoundOrConstraint(result.get(1), integer, integer, EQUALITY, Constraint.class);
}
Aggregations