} else if (this.left instanceof AllocationExpression && this.left.isPolyExpression()) {
// half-resolved diamond has a resolvedType, but that may not be the final word, try one more step of resolution:
MethodBinding binding = ((AllocationExpression) this.left).binding(this.right, false, null);
return (binding != null && binding.declaringClass.isCompatibleWith(this.right, inferenceContext.scope)) ? TRUE : FALSE;
} else if (this.left instanceof Invocation && this.left.isPolyExpression()) {
Invocation invoc = (Invocation) this.left;
MethodBinding binding = invoc.binding(this.right, false, null);
if (binding instanceof ParameterizedGenericMethodBinding) {
ParameterizedGenericMethodBinding method = (ParameterizedGenericMethodBinding) binding;
InferenceContext18 leftCtx = invoc.getInferenceContext(method);
if (leftCtx.stepCompleted < InferenceContext18.TYPE_INFERRED) {
break proper; // fall through into nested inference below (not explicit in the spec!)
}
}
}
return FALSE;
}
if (!canBePolyExpression(this.left)) {
TypeBinding exprType = this.left.resolvedType;
if (exprType == null || !exprType.isValidBinding())
return FALSE;
return ConstraintTypeFormula.create(exprType, this.right, COMPATIBLE, this.isSoft);
} else {
// shapes of poly expressions (18.2.1)
// - parenthesized expression : these are transparent in our AST
if (this.left instanceof Invocation) {
Invocation invocation = (Invocation) this.left;
MethodBinding previousMethod = invocation.binding(this.right, false, null);
if (previousMethod == null) // can happen, e.g., if inside a copied lambda with ignored errors
return null; // -> proceed with no new constraints
MethodBinding method = previousMethod;
// ignore previous (inner) inference result and do a fresh start:
// avoid original(), since we only want to discard one level of instantiation
// (method type variables - not class type variables)!
method = previousMethod.shallowOriginal();
SuspendedInferenceRecord prevInvocation = inferenceContext.enterPolyInvocation(invocation, invocation.arguments());
// Invocation Applicability Inference: 18.5.1 & Invocation Type Inference: 18.5.2
try {
Expression[] arguments = invocation.arguments();
TypeBinding[] argumentTypes = arguments == null ? Binding.NO_PARAMETERS : new TypeBinding[arguments.length];
for (int i = 0; i < argumentTypes.length; i++)
argumentTypes[i] = arguments[i].resolvedType;
if (previousMethod instanceof ParameterizedGenericMethodBinding) {
// find the previous inner inference context to see what inference kind this invocation needs:
InferenceContext18 innerCtx = invocation.getInferenceContext((ParameterizedGenericMethodBinding) previousMethod);
if (innerCtx == null) { // no inference -> assume it wasn't really poly after all
TypeBinding exprType = this.left.resolvedType;
if (exprType == null || !exprType.isValidBinding())
return FALSE;
return ConstraintTypeFormula.create(exprType, this.right, COMPATIBLE, this.isSoft);