@Override protected void copyTypeArguments(ParameterizedTypeReference result, ITypeReferenceOwner owner) { super.copyTypeArguments(result, owner); FunctionTypeReference casted = (FunctionTypeReference) result; if (parameterTypes != null && !parameterTypes.isEmpty()) { for(LightweightTypeReference typeArgument: parameterTypes) { casted.addParameterType(typeArgument.copyInto(owner)); } } if (returnType != null) { casted.setReturnType(returnType.copyInto(owner)); } }
protected FunctionTypeReference getAsFunctionOrNull(ParameterizedTypeReference typeReference) { if (typeReference.isRawType()) return null; FunctionTypeReference functionType = new FunctionTypeReference(typeReference.getOwner(), typeReference.getType()); List<LightweightTypeReference> allTypeArguments = typeReference.getTypeArguments(); if (!tryAssignTypeArguments(allTypeArguments.subList(0, allTypeArguments.size() - 1), functionType)) return null; LightweightTypeReference lastTypeArgument = allTypeArguments.get(allTypeArguments.size() - 1); functionType.addTypeArgument(lastTypeArgument); LightweightTypeReference returnType = lastTypeArgument.getUpperBoundSubstitute(); functionType.setReturnType(returnType); return functionType; }
if (returnType == null) throw new IllegalStateException("return type shall not be null"); resultClosureType.setReturnType(returnType); if (validParameterTypes && returnType.isPrimitiveVoid()) { return ConformanceFlags.INCOMPATIBLE; if (!expressionResultType.isPrimitiveVoid()) { if (expectedReturnType.isPrimitiveVoid()) { resultClosureType.setReturnType(expectedReturnType); if (isImplicitReturn(expressionResult)) { return ConformanceFlags.NONE; resultClosureType.setReturnType(expressionResultType); if (validParameterTypes && isImplicitReturn(expressionResult)) { return ConformanceFlags.LAMBDA_VOID_COMPATIBLE; resultClosureType.setReturnType(expressionResultType); } else if (expectedReturnType.isPrimitiveVoid()) { resultClosureType.setReturnType(expectedReturnType); return ConformanceFlags.INCOMPATIBLE; } else { resultClosureType.setReturnType(expectedReturnType); return ConformanceFlags.LAMBDA_RAW_COMPATIBLE;
protected FunctionTypeReference processExpressionType(FunctionTypeReference incompleteClosureType, ITypeComputationResult expressionResult) { LightweightTypeReference expressionResultType = expressionResult.getReturnType(); if (expressionResultType == null || !expressionResultType.isPrimitiveVoid()) { FunctionTypeReference result = getFunctionTypeReference(false); LightweightTypeReference expectedReturnType = result.getTypeArguments().get(result.getTypeArguments().size() - 1); if (expressionResultType != null && !expressionResultType.isAny()) { result.setReturnType(expressionResultType); deferredBindTypeArgument(expectedReturnType, expressionResultType, BoundTypeArgumentSource.INFERRED); } else { LightweightTypeReference objectTypeReference = incompleteClosureType.getOwner().newReferenceToObject(); result.setReturnType(objectTypeReference); deferredBindTypeArgument(expectedReturnType, objectTypeReference, BoundTypeArgumentSource.INFERRED); } List<LightweightTypeReference> incompleteParameterTypes = incompleteClosureType.getParameterTypes(); for(int i = 0; i < incompleteParameterTypes.size(); i++) { result.addParameterType(incompleteParameterTypes.get(i)); } List<LightweightTypeReference> incompleteTypeArguments = incompleteClosureType.getTypeArguments(); List<LightweightTypeReference> resultTypeArguments = result.getTypeArguments(); for(int i = 0; i < incompleteTypeArguments.size(); i++) { deferredBindTypeArgument(resultTypeArguments.get(i), incompleteTypeArguments.get(i), BoundTypeArgumentSource.INFERRED); } return result; } else { incompleteClosureType.setReturnType(expressionResultType); return incompleteClosureType; } }
protected void enhanceFunctionType(FunctionTypeReference reference, FunctionTypeReference result, Visiting visiting) { for(LightweightTypeReference parameterType: reference.getParameterTypes()) { result.addParameterType(visitTypeArgument(parameterType, visiting, true)); } for(LightweightTypeReference typeArgument: reference.getTypeArguments()) { result.addTypeArgument(visitTypeArgument(typeArgument, visiting)); } LightweightTypeReference returnType = reference.getReturnType(); if (returnType != null) { result.setReturnType(visitTypeArgument(returnType, visiting)); } }
protected FunctionTypeReference getAsProcedureOrNull(ParameterizedTypeReference typeReference) { ITypeReferenceOwner owner = typeReference.getOwner(); JvmType type = typeReference.getType(); FunctionTypeReference functionType = new FunctionTypeReference(owner, type); if (!tryAssignTypeArguments(typeReference.getTypeArguments(), functionType)) return null; JvmType voidType = (JvmType) owner.getContextResourceSet().getEObject(URIHelperConstants.PRIMITIVES_URI.appendFragment("void"), true); functionType.setReturnType(owner.newParameterizedTypeReference(voidType)); return functionType; }
private FunctionTypeReference createFunctionTypeRef( ITypeReferenceOwner owner, LightweightTypeReference functionType, List<LightweightTypeReference> parameterTypes, /* @Nullable */ LightweightTypeReference returnType, /* @Nullable */ LightweightTypeReference outer) { JvmType type = functionType.getType(); if (type == null) throw new IllegalArgumentException("type may not be null"); FunctionTypeReference result; if (outer == null) { result = owner.newFunctionTypeReference(type); } else { result = owner.newFunctionTypeReference(outer, type); } if (functionType instanceof ParameterizedTypeReference) { for(LightweightTypeReference typeArgument: ((ParameterizedTypeReference) functionType).getTypeArguments()) { result.addTypeArgument(typeArgument.copyInto(owner)); } } for(LightweightTypeReference parameterType: parameterTypes) { result.addParameterType(parameterType.copyInto(owner)); } if (returnType != null) { result.setReturnType(returnType.copyInto(owner)); } return result; }
result.addParameterType(lowerBound); result.setReturnType(substitutor.substitute(declaredReturnType)); return result;
protected LocalTypeSubstitutor.SubstitutionResult doSubstituteFunctionType(FunctionTypeReference reference, FunctionTypeReference result, boolean didSubstitute) { for(LightweightTypeReference parameterType: reference.getParameterTypes()) { SubstitutionResult visited = visitTypeArgument(parameterType, VarianceInfo.IN); didSubstitute = didSubstitute || visited.didSubstitute; result.addParameterType(visited.typeReference); } for(LightweightTypeReference typeArgument: reference.getTypeArguments()) { SubstitutionResult visited = visitTypeArgument(typeArgument, VarianceInfo.INVARIANT); didSubstitute = didSubstitute || visited.didSubstitute; result.addTypeArgument(visited.typeReference); } LightweightTypeReference returnType = reference.getReturnType(); if (returnType != null) { SubstitutionResult visited = visitTypeArgument(returnType, VarianceInfo.OUT); didSubstitute = didSubstitute || visited.didSubstitute; result.setReturnType(visited.typeReference); } return new SubstitutionResult(result, didSubstitute); }
result.setReturnType(substituted); return result;
@Override public LightweightTypeReference doVisitFunctionTypeReference(XFunctionTypeRef reference) { JvmTypeReference equivalent = reference.getEquivalent(); if (equivalent == null) { return super.doVisitFunctionTypeReference(reference); } FunctionTypeReference result; // constructors used below to avoid subsequent checks for isInner which was supposed to be done by // the computation of the equivalent if (equivalent.eClass() == TypesPackage.Literals.JVM_INNER_TYPE_REFERENCE) { JvmParameterizedTypeReference outer = ((JvmInnerTypeReference) equivalent).getOuter(); LightweightTypeReference outerEquivalent = outer.accept(this); result = new InnerFunctionTypeReference(owner, outerEquivalent, reference.getType()); } else { result = new FunctionTypeReference(owner, reference.getType()); } if (equivalent instanceof JvmParameterizedTypeReference) { for(JvmTypeReference argument: ((JvmParameterizedTypeReference)equivalent).getArguments()) { result.addTypeArgument(visit(argument)); } } for(JvmTypeReference parameter: reference.getParamTypes()) { result.addParameterType(visit(parameter)); } if (reference.getReturnType() != null) { result.setReturnType(visit(reference.getReturnType())); } return result; }
if (_tripleNotEquals) { final LightweightTypeReference returnType = this.visit(this.wrapIfNecessary(reference.getReturnType())); result.setReturnType(returnType); if ((reference instanceof XFunctionTypeRefImplCustom)) { boolean _isProcedure = this.isProcedure(((XFunctionTypeRefImplCustom)reference));