if (this.left instanceof LambdaExpression) {
if (this.right instanceof InferenceVariable) {
return Collections.singletonList((InferenceVariable)this.right);
}
if (this.right.isFunctionalInterface(context.scope)) {
LambdaExpression lambda = (LambdaExpression) this.left;
MethodBinding sam = this.right.getSingleAbstractMethod(context.scope, true); // TODO derive with target type?
final Set<InferenceVariable> variables = new HashSet<InferenceVariable>();
if (lambda.argumentsTypeElided()) {
// i)
int len = sam.parameters.length;
for (int i = 0; i < len; i++) {
sam.parameters[i].collectInferenceVariables(variables);
}
}
if (sam.returnType != TypeBinding.VOID) {
// ii)
final TypeBinding r = sam.returnType;
Statement body = lambda.body();
if (body instanceof Expression) {
variables.addAll(new ConstraintExpressionFormula((Expression) body, r, COMPATIBLE).inputVariables(context));
} else {
// TODO: should I use LambdaExpression.resultExpressions? (is currently private).
body.traverse(new ASTVisitor() {