Class TypeInferenceResolver
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.typeresolution.typeinference.TypeInferenceResolver
-
public final class TypeInferenceResolver extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TypeInferenceResolver.ResolutionFailedException
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
boundsHaveAnEqualityBetween(java.util.List<Variable> firstList, Variable second, java.util.List<Bound> bounds)
static java.util.Set<java.lang.Class<?>>
getErasedCandidateSet(java.util.List<JavaTypeDefinition> erasedSuperTypeSets)
static java.util.Map<Variable,JavaTypeDefinition>
getInstantiations(java.util.List<Bound> bounds)
static java.util.List<JavaTypeDefinition>
getLowerBoundsOf(Variable var, java.util.List<Bound> bounds)
static java.util.Set<Variable>
getMentionedVariables(java.util.List<Bound> bounds)
static java.util.Set<java.lang.Class<?>>
getMinimalErasedCandidateSet(java.util.Set<java.lang.Class<?>> erasedSet)
static java.util.Set<Variable>
getUninstantiatedVariables(java.util.List<Bound> bounds)
static java.util.Map<Variable,java.util.Set<Variable>>
getVariableDependencies(java.util.List<Bound> bounds)
static java.util.List<Constraint>
incorporateBounds(java.util.List<Bound> currentBounds, java.util.List<Bound> newBounds)
https://docs.oracle.com/javase/specs/jls/se8/html/jls-18.html#jls-18.3static java.util.List<JavaTypeDefinition>
inferTypes(java.util.List<Constraint> constraints, java.util.List<Bound> bounds, java.util.List<Variable> variables)
static JavaTypeDefinition
intersect(JavaTypeDefinition first, JavaTypeDefinition second)
static boolean
isProperSubsetOfVariables(java.util.List<Variable> variables, java.util.Map<Variable,JavaTypeDefinition> instantiations, java.util.Map<Variable,java.util.Set<Variable>> dependencies, java.util.List<Bound> bounds)
Given a set of inference variables to resolve, let V be the union of this set and all variables upon which the resolution of at least one variable in this set depends.static JavaTypeDefinition
lub(java.util.List<JavaTypeDefinition> types)
static JavaTypeDefinition
merge(JavaTypeDefinition first, JavaTypeDefinition second)
Merge two types of the same class to something both can be assigned to and is most specific.static java.util.Map<Variable,JavaTypeDefinition>
resolveVariables(java.util.List<Bound> bounds)
Resolve unresolved variables in a list of bounds.
-
-
-
Method Detail
-
inferTypes
public static java.util.List<JavaTypeDefinition> inferTypes(java.util.List<Constraint> constraints, java.util.List<Bound> bounds, java.util.List<Variable> variables)
-
lub
public static JavaTypeDefinition lub(java.util.List<JavaTypeDefinition> types)
-
intersect
public static JavaTypeDefinition intersect(JavaTypeDefinition first, JavaTypeDefinition second)
- Returns:
- the intersection of the two types
-
merge
public static JavaTypeDefinition merge(JavaTypeDefinition first, JavaTypeDefinition second)
Merge two types of the same class to something both can be assigned to and is most specific.
-
getErasedCandidateSet
public static java.util.Set<java.lang.Class<?>> getErasedCandidateSet(java.util.List<JavaTypeDefinition> erasedSuperTypeSets)
-
getMinimalErasedCandidateSet
public static java.util.Set<java.lang.Class<?>> getMinimalErasedCandidateSet(java.util.Set<java.lang.Class<?>> erasedSet)
-
resolveVariables
public static java.util.Map<Variable,JavaTypeDefinition> resolveVariables(java.util.List<Bound> bounds)
Resolve unresolved variables in a list of bounds.
-
getLowerBoundsOf
public static java.util.List<JavaTypeDefinition> getLowerBoundsOf(Variable var, java.util.List<Bound> bounds)
-
isProperSubsetOfVariables
public static boolean isProperSubsetOfVariables(java.util.List<Variable> variables, java.util.Map<Variable,JavaTypeDefinition> instantiations, java.util.Map<Variable,java.util.Set<Variable>> dependencies, java.util.List<Bound> bounds)
Given a set of inference variables to resolve, let V be the union of this set and all variables upon which the resolution of at least one variable in this set depends....
Otherwise, let { α1, ..., αn } be a non-empty subset of uninstantiated variables in V such that i) for all i (1 ≤ i ≤ n), if αi depends on the resolution of a variable β, then either β has an instantiation or there is some j such that β = αj; and Resolution proceeds by generating an instantiation for each of α1, ..., αn based on the bounds in the bound set:
- Returns:
- true, if 'variables' is a resolvable subset
-
boundsHaveAnEqualityBetween
public static boolean boundsHaveAnEqualityBetween(java.util.List<Variable> firstList, Variable second, java.util.List<Bound> bounds)
- Returns:
- true, if 'bounds' contains an equality between 'second' and an element from 'firstList'
-
getInstantiations
public static java.util.Map<Variable,JavaTypeDefinition> getInstantiations(java.util.List<Bound> bounds)
- Returns:
- A map of variable -> proper type produced by searching for α = T or T = α bounds
-
getUninstantiatedVariables
public static java.util.Set<Variable> getUninstantiatedVariables(java.util.List<Bound> bounds)
- Returns:
- A list of variables which have no direct instantiations
-
getVariableDependencies
public static java.util.Map<Variable,java.util.Set<Variable>> getVariableDependencies(java.util.List<Bound> bounds)
-
getMentionedVariables
public static java.util.Set<Variable> getMentionedVariables(java.util.List<Bound> bounds)
- Returns:
- a set of variables mentioned by the bounds
-
incorporateBounds
public static java.util.List<Constraint> incorporateBounds(java.util.List<Bound> currentBounds, java.util.List<Bound> newBounds)
https://docs.oracle.com/javase/specs/jls/se8/html/jls-18.html#jls-18.3
-
-