public class InferenceContext18
extends java.lang.Object
InferenceVariableConstraintFormulaTypeBoundBoundSet.captures, throws-bounds in BoundSet.inThrows.BoundSet: main state during inference.InferenceContext18 manages instances of the above and coordinates the inference process.
TypeBinding.isProperType(boolean):
used to exclude "types" that mention inference variables (18.1.1).TypeBinding.mentionsAny(TypeBinding[], int):
does the receiver type binding mention any of the given types?TypeBinding.substituteInferenceVariable(InferenceVariable, TypeBinding):
replace occurrences of an inference variable with a proper type.TypeBinding.collectInferenceVariables(Set):
collect all inference variables mentioned in the receiver type into the given set.TypeVariableBinding.getTypeBounds(InferenceVariable, InferenceSubstitution):
Compute the initial type bounds for one inference variable as per JLS8 sect 18.1.3.reduce() with most work happening in implementations of
ConstraintFormula.reduce(InferenceContext18):
ConstraintExpressionFormula.reduce(InferenceContext18).ConstraintTypeFormula.reduce(InferenceContext18).BoundSet.incorporate(InferenceContext18); during inference new constraints
are accepted via BoundSet.reduceOneConstraint(InferenceContext18, ConstraintFormula) (combining 18.2 & 18.3)resolve(InferenceVariable[]).
currentBounds, whereas
the last phase returns the resulting bound set while keeping the previous state in currentBounds.
inferInvocationApplicability(MethodBinding, TypeBinding[], boolean). Prepare the initial state for
inference of a generic invocation - no target type used at this point.
Need to call solve(boolean) with true afterwards to produce the intermediate result.Scope.findMethod(ReferenceBinding, char[], TypeBinding[], InvocationSite, boolean) et al
to select applicable methods into overload resolution.inferInvocationType(TypeBinding, InvocationSite, MethodBinding). After a
most specific method has been picked, and given a target type determine the final generic instantiation.
As long as a target type is still unavailable this phase keeps getting deferred.
Different wrappers exist for the convenience of different callers.FunctionalExpression.resolveType(BlockScope).ParameterizedGenericMethodBinding.computeCompatibleMethod(MethodBinding, TypeBinding[], Scope, InvocationSite).
CHECK_LOOSE. Only if that fails, another attempt is made in mode CHECK_VARARG.
Which of these two attempts was successful is stored in inferenceKind.
This field must be consulted whenever arguments of an invocation should be further processed.
See also getParameter(TypeBinding[], int, boolean) and its clients.| Modifier and Type | Field and Description |
|---|---|
static int |
APPLICABILITY_INFERRED
Applicability Inference (18.5.1) has been completed.
|
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet |
b2 |
static int |
CHECK_LOOSE |
static int |
CHECK_STRICT |
static int |
CHECK_UNKNOWN |
static int |
CHECK_VARARG |
java.util.List<org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ConstraintFormula> |
constraintsWithUncheckedConversion
Signals whether any type compatibility makes use of unchecked conversion.
|
static int |
NOT_INFERRED |
InferenceContext18 |
outerContext |
int |
stepCompleted
Marks how much work has been done so far? Used to avoid performing any of these tasks more than once.
|
static int |
TYPE_INFERRED
Invocation Type Inference (18.5.2) has been completed (for some target type).
|
boolean |
usesUncheckedConversion |
| Constructor and Description |
|---|
InferenceContext18(Scope scope) |
InferenceContext18(Scope scope,
Expression[] arguments,
InvocationSite site,
InferenceContext18 outerContext)
Construct an inference context for an invocation (method/constructor).
|
| Modifier and Type | Method and Description |
|---|---|
void |
addThrowsContraints(TypeBinding[] parameters,
InferenceVariable[] variables,
ReferenceBinding[] thrownExceptions)
JLS 18.1.3 Bounds: throws α: the inference variable α appears in a throws clause
|
InferenceVariable[] |
addTypeVariableSubstitutions(TypeBinding[] typeVariables)
Add new inference variables for the given type variables.
|
void |
cleanUp() |
InferenceVariable[] |
createInitialBoundSet(TypeVariableBinding[] typeParameters)
JLS 18.1.3: Create initial bounds from a given set of type parameters declarations.
|
void |
createInitialConstraintsForParameters(TypeBinding[] parameters,
boolean checkVararg,
TypeBinding varArgsType,
MethodBinding method)
JLS 18.5.1: compute bounds from formal and actual parameters.
|
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.SuspendedInferenceRecord |
enterLambda(LambdaExpression lambda) |
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.SuspendedInferenceRecord |
enterPolyInvocation(InvocationSite invocation,
Expression[] innerArguments) |
void |
forwardResults(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet result,
Invocation invocation,
ParameterizedMethodBinding pmb,
TypeBinding targetType) |
TypeBinding[] |
getFunctionInterfaceArgumentSolutions(TypeBinding[] a) |
protected int |
getInferenceKind(MethodBinding nonGenericMethod,
TypeBinding[] argumentTypes) |
static TypeBinding |
getParameter(TypeBinding[] parameters,
int rank,
boolean isVarArgs)
Retrieve the rank'th parameter, possibly respecting varargs invocation, see 15.12.2.4.
|
MethodBinding |
getReturnProblemMethodIfNeeded(TypeBinding expectedType,
MethodBinding method)
Create a problem method signaling failure of invocation type inference,
unless the given candidate is tolerable to be compatible with buggy javac.
|
TypeBinding[] |
getSolutions(TypeVariableBinding[] typeParameters,
InvocationSite site,
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet boundSet)
Retrieve the resolved solutions for all given type variables.
|
ReferenceBinding |
inferFunctionalInterfaceParameterization(LambdaExpression lambda,
BlockScope blockScope,
ParameterizedTypeBinding targetTypeWithWildCards)
18.5.3 Functional Interface Parameterization Inference
|
void |
inferInvocationApplicability(MethodBinding method,
TypeBinding[] arguments,
boolean isDiamond)
JLS 18.5.1 Invocation Applicability Inference.
|
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet |
inferInvocationType(TypeBinding expectedType,
InvocationSite invocationSite,
MethodBinding method)
JLS 18.5.2 Invocation Type Inference
|
void |
integrateInnerInferenceB2(InferenceContext18 innerCtx) |
boolean |
isMoreSpecificThan(MethodBinding m1,
MethodBinding m2,
boolean isVarArgs,
boolean isVarArgs2)
18.5.4 More Specific Method Inference
|
boolean |
isResolved(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet boundSet)
Have all inference variables been instantiated successfully?
|
static boolean |
isSameSite(InvocationSite site1,
InvocationSite site2) |
boolean |
isVarArgs() |
static void |
missingImplementation(java.lang.String msg) |
static ParameterizedTypeBinding |
parameterizedWithWildcard(TypeBinding type)
If 'type' is a parameterized type and one of its arguments is a wildcard answer the casted type, else null.
|
void |
recordUncheckedConversion(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ConstraintTypeFormula constraint)
Record the fact that the given constraint requires unchecked conversion.
|
boolean |
reduceAndIncorporate(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ConstraintFormula constraint)
When inference produces a new constraint, reduce it to a suitable type bound and add the latter to the bound set.
|
boolean |
reduceWithEqualityConstraints(TypeBinding[] p,
TypeBinding[] q) |
void |
resumeSuspendedInference(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.SuspendedInferenceRecord record) |
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet |
solve() |
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet |
solve(boolean inferringApplicability)
Try to solve the inference problem defined by constraints and bounds previously registered.
|
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet |
solve(InferenceVariable[] toResolve) |
TypeBinding |
substitute(TypeBinding type)
Substitute any type variables mentioned in 'type' by the corresponding inference variable, if one exists.
|
java.lang.String |
toString() |
boolean |
usesUncheckedConversion()
For use by 15.12.2.6 Method Invocation Type
|
public int stepCompleted
public static final int NOT_INFERRED
public static final int APPLICABILITY_INFERRED
public static final int TYPE_INFERRED
public java.util.List<org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ConstraintFormula> constraintsWithUncheckedConversion
public boolean usesUncheckedConversion
public InferenceContext18 outerContext
public org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet b2
public static final int CHECK_UNKNOWN
public static final int CHECK_STRICT
public static final int CHECK_LOOSE
public static final int CHECK_VARARG
public InferenceContext18(Scope scope, Expression[] arguments, InvocationSite site, InferenceContext18 outerContext)
public InferenceContext18(Scope scope)
public static boolean isSameSite(InvocationSite site1, InvocationSite site2)
public InferenceVariable[] createInitialBoundSet(TypeVariableBinding[] typeParameters)
public TypeBinding substitute(TypeBinding type)
public void createInitialConstraintsForParameters(TypeBinding[] parameters, boolean checkVararg, TypeBinding varArgsType, MethodBinding method)
public InferenceVariable[] addTypeVariableSubstitutions(TypeBinding[] typeVariables)
public void addThrowsContraints(TypeBinding[] parameters, InferenceVariable[] variables, ReferenceBinding[] thrownExceptions)
public void inferInvocationApplicability(MethodBinding method, TypeBinding[] arguments, boolean isDiamond)
public org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet inferInvocationType(TypeBinding expectedType, InvocationSite invocationSite, MethodBinding method) throws InferenceFailureException
InferenceFailureExceptionprotected int getInferenceKind(MethodBinding nonGenericMethod, TypeBinding[] argumentTypes)
public ReferenceBinding inferFunctionalInterfaceParameterization(LambdaExpression lambda, BlockScope blockScope, ParameterizedTypeBinding targetTypeWithWildCards)
public boolean reduceWithEqualityConstraints(TypeBinding[] p, TypeBinding[] q)
public boolean isMoreSpecificThan(MethodBinding m1, MethodBinding m2, boolean isVarArgs, boolean isVarArgs2)
public org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet solve(boolean inferringApplicability)
throws InferenceFailureException
InferenceFailureException - a compile error has been detected during inferencepublic org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet solve()
throws InferenceFailureException
InferenceFailureExceptionpublic org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet solve(InferenceVariable[] toResolve) throws InferenceFailureException
InferenceFailureExceptionpublic boolean isResolved(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet boundSet)
public TypeBinding[] getSolutions(TypeVariableBinding[] typeParameters, InvocationSite site, org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet boundSet)
typeParameters - boundSet - where instantiations are to be foundnull elements for any type variable that could not be substituted.public boolean reduceAndIncorporate(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ConstraintFormula constraint)
throws InferenceFailureException
InferenceFailureExceptionpublic org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.SuspendedInferenceRecord enterPolyInvocation(InvocationSite invocation, Expression[] innerArguments)
public org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.SuspendedInferenceRecord enterLambda(LambdaExpression lambda)
public void integrateInnerInferenceB2(InferenceContext18 innerCtx)
public void resumeSuspendedInference(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.SuspendedInferenceRecord record)
public boolean isVarArgs()
public static TypeBinding getParameter(TypeBinding[] parameters, int rank, boolean isVarArgs)
public MethodBinding getReturnProblemMethodIfNeeded(TypeBinding expectedType, MethodBinding method)
public java.lang.String toString()
toString in class java.lang.Objectpublic static ParameterizedTypeBinding parameterizedWithWildcard(TypeBinding type)
public TypeBinding[] getFunctionInterfaceArgumentSolutions(TypeBinding[] a)
public void recordUncheckedConversion(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ConstraintTypeFormula constraint)
public boolean usesUncheckedConversion()
public static void missingImplementation(java.lang.String msg)
public void forwardResults(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BoundSet result,
Invocation invocation,
ParameterizedMethodBinding pmb,
TypeBinding targetType)
public void cleanUp()