@Override public JvmOperation getOperation() { JvmOperation result = functionTypes.findImplementingOperation(getExpectedClosureType()); if (result == null) { throw new IllegalStateException(); } return result; }
public JvmOperation findImplementingOperation(LightweightTypeReference functionType) { // avoid to trigger resolution of currently unbound type arguments // since the computation of this' lambdas type may enhance the information // about the given unbound type if (functionType.getKind() == LightweightTypeReference.KIND_UNBOUND_TYPE_REFERENCE && !functionType.isResolved()) { JvmOperation result = findImplementingOperation((UnboundTypeReference)functionType); if (result != null) { return result; } } List<JvmType> rawTypes = functionType.getRawTypes(); JvmOperation result = findImplementingOperation(rawTypes); return result; }
protected JvmOperation findImplementingOperation(LightweightTypeReference closureType) { return getTypeComputationServices().getFunctionTypes().findImplementingOperation(closureType); }
private JvmOperation findImplementingOperation(UnboundTypeReference unboundTypeReference) { List<LightweightBoundTypeArgument> hints = unboundTypeReference.getAllHints(); for(LightweightBoundTypeArgument hint: hints) { LightweightTypeReference hintReference = hint.getTypeReference(); if (hintReference != null && (hint.getSource() == BoundTypeArgumentSource.INFERRED || hint.getSource() == BoundTypeArgumentSource.INFERRED_EXPECTATION)) { List<JvmType> rawTypes = hintReference.getRawTypes(); JvmOperation result = findImplementingOperation(rawTypes); if (result != null) { return result; } } } return null; }
/** * This method is only public for testing purpose. * * @noreference This method is not intended to be referenced by clients. */ public void selectStrategy() { LightweightTypeReference expectedType = expectation.getExpectedType(); if (expectedType == null) { strategy = getClosureWithoutExpectationHelper(); } else { JvmOperation operation = functionTypes.findImplementingOperation(expectedType); JvmType type = expectedType.getType(); int closureParameterSize; if (closure.isExplicitSyntax()) { closureParameterSize = closure.getDeclaredFormalParameters().size(); } else if (operation != null) { closureParameterSize = operation.getParameters().size(); } else { closureParameterSize = 1; } if (operation == null || operation.getParameters().size() != closureParameterSize || type == null) { strategy = getClosureWithoutExpectationHelper(); } else { strategy = createClosureWithExpectationHelper(operation); } } }
if (declaredType != null && !declaredType.isType(Object.class)) { CommonTypeComputationServices services = getState().getReferenceOwner().getServices(); JvmOperation operation = services.getFunctionTypes().findImplementingOperation(declaredType); if (operation == null) { return false;
JvmOperation operation = findImplementingOperation(typeReference); if (operation == null) return null;
return; } else { JvmOperation operation = getServices().getFunctionTypes().findImplementingOperation(type); if (operation == null) { error("There is no context to infer the closure's argument types from. Consider typing the arguments or use the closures in a more specific context.",