use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.Constraint 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.Constraint 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.Constraint 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);
}
use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.Constraint in project pmd by pmd.
the class TypeInferenceTest method testSubtypeReduceVariableVsAny.
@Test
public void testSubtypeReduceVariableVsAny() {
// Otherwise, if S is an inference variable, α, the constraint reduces to the bound α <: T.
List<BoundOrConstraint> result = new Constraint(alpha, integer, SUBTYPE).reduce();
assertEquals(1, result.size());
testBoundOrConstraint(result.get(0), alpha, integer, SUBTYPE, Bound.class);
}
use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.Constraint in project pmd by pmd.
the class TypeInferenceTest method testEqualityReduceVariableVsNotPrimitive.
@Test
public void testEqualityReduceVariableVsNotPrimitive() {
// Otherwise, if S is an inference variable, α, and T is not a primitive type, the constraint reduces to
// the bound α = T.
List<BoundOrConstraint> result = new Constraint(alpha, number, EQUALITY).reduce();
assertEquals(1, result.size());
testBoundOrConstraint(result.get(0), alpha, number, EQUALITY, Bound.class);
}
Aggregations