/** * @param callArguments * @param receiver * @deprecated this method is unused, replaced with {@link DelegatesTo} inference. */ @Deprecated protected void checkClosureParameters(final Expression callArguments, final ClassNode receiver) { if (callArguments instanceof ArgumentListExpression) { ArgumentListExpression argList = (ArgumentListExpression) callArguments; ClosureExpression closure = (ClosureExpression) argList.getExpression(0); Parameter[] parameters = closure.getParameters(); if (parameters.length > 1) { addStaticTypeError("Unexpected number of parameters for a with call", argList); } else if (parameters.length == 1) { Parameter param = parameters[0]; if (!param.isDynamicTyped() && !isAssignableTo(receiver, param.getType().redirect())) { addStaticTypeError("Expected parameter type: " + receiver.toString(false) + " but was: " + param.getType().redirect().toString(false), param); } } closure.putNodeMetaData(StaticTypesMarker.DELEGATION_METADATA, new DelegationMetadata( receiver, Closure.DELEGATE_FIRST, typeCheckingContext.delegationMetadata )); } }
blockParameterTypes = new ClassNode[p.length]; for (int i = 0; i < p.length; i++) { if (p[i] != null && !p[i].isDynamicTyped()) { blockParameterTypes[i] = p[i].getType(); } else {
private static OffsetRange getParameterRange(Parameter param, BaseDocument doc, int cursorOffset) { if (param.isDynamicTyped()) { return OffsetRange.NONE; } return getRange(param, doc, cursorOffset); }
@Override public void visitClosureExpression(ClosureExpression expression) { secondPass = false; if (expression.getCode() == null || expression.getCode() instanceof EmptyStatement) { addError("[GContracts] Annotation does not contain any expressions (e.g. use '@Requires({ argument1 })').", expression); } if (expression.getCode() instanceof BlockStatement && ((BlockStatement) expression.getCode()).getStatements().isEmpty()) { addError("[GContracts] Annotation does not contain any expressions (e.g. use '@Requires({ argument1 })').", expression); } if (expression.isParameterSpecified() && !AnnotationUtils.hasAnnotationOfType(annotationNode.getClassNode(), POSTCONDITION_TYPE_NAME)) { addError("[GContracts] Annotation does not support parameters (the only exception are postconditions).", expression); } if (expression.isParameterSpecified()) { for (Parameter param : expression.getParameters()) { if (!("result".equals(param.getName()) || "old".equals(param.getName()))) { addError("[GContracts] Postconditions only allow 'old' and 'result' closure parameters.", expression); } if (!param.isDynamicTyped()) { addError("[GContracts] Postconditions do not support explicit types.", expression); } } } super.visitClosureExpression(expression); }