use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.Constraint in project pmd by pmd.
the class TypeInferenceTest method testLooseInvocationLeftBoxing.
@Test
public void testLooseInvocationLeftBoxing() {
// Otherwise, if S is a primitive type, let S' be the result of applying boxing conversion (§5.1.7) to S.
// Then the constraint reduces to ‹S' → T›.
List<BoundOrConstraint> result = new Constraint(primitiveInt, number, LOOSE_INVOCATION).reduce();
assertEquals(1, result.size());
testBoundOrConstraint(result.get(0), integer, number, LOOSE_INVOCATION, Constraint.class);
}
use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.Constraint in project pmd by pmd.
the class TypeInferenceTest method testEqualityReduceArrayTypes.
@Test
public void testEqualityReduceArrayTypes() {
// Otherwise, if S and T are array types, S'[] and T'[], the constraint reduces to ‹S' = T'›.
List<BoundOrConstraint> result = new Constraint(JavaTypeDefinition.forClass(Number[].class), JavaTypeDefinition.forClass(Integer[].class), EQUALITY).reduce();
assertEquals(1, result.size());
testBoundOrConstraint(result.get(0), number, integer, EQUALITY, Constraint.class);
}
use of net.sourceforge.pmd.lang.java.typeresolution.typeinference.Constraint 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.Constraint 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.Constraint in project pmd by pmd.
the class TypeInferenceTest method testEqualityReduceProperVsProper.
@Test
public void testEqualityReduceProperVsProper() {
// If S and T are proper types, the constraint reduces to true if S is the same as T (§4.3.4), and false
// otherwise.
assertTrue(new Constraint(number, number, EQUALITY).reduce().isEmpty());
assertNull(new Constraint(number, integer, EQUALITY).reduce());
// Otherwise, if S or T is the null type, the constraint reduces to false. TODO
}
Aggregations