public FunctionTypeReference createRawFunctionTypeRef(ITypeReferenceOwner owner, EObject context, int parameterCount, boolean procedure) { String simpleClassName = (procedure ? "Procedure" : "Function") + Math.min(6, parameterCount); final Class<?> loadFunctionClass = loadFunctionClass(simpleClassName, procedure); JvmType declaredType = typeReferences.findDeclaredType(loadFunctionClass, context); if (declaredType == null || !(declaredType instanceof JvmTypeParameterDeclarator)) throw new IllegalStateException("Cannot load raw function type ref"); FunctionTypeReference result = owner.newFunctionTypeReference(declaredType); return result; }
@Override protected LocalTypeSubstitutor.SubstitutionResult doVisitFunctionTypeReference(FunctionTypeReference reference, VarianceInfo varianceInfo) { FunctionTypeReference result = owner.newFunctionTypeReference(reference.getType()); return doSubstituteFunctionType(reference, result, false); }
protected void prepareResultType() { resultClosureType = expectedClosureType.getOwner().newFunctionTypeReference(expectedClosureType.getType()); for (LightweightTypeReference argument : expectedClosureType.getTypeArguments()) { resultClosureType.addTypeArgument(argument); } }
@Override protected SubstitutionResult doVisitInnerFunctionTypeReference(InnerFunctionTypeReference reference, VarianceInfo varianceInfo) { SubstitutionResult visitedOuter = reference.getOuter().accept(this, varianceInfo); InnerFunctionTypeReference result = owner.newFunctionTypeReference(visitedOuter.typeReference, reference.getType()); return doSubstituteFunctionType(reference, result, visitedOuter.didSubstitute); }
@Override protected LightweightTypeReference doVisitFunctionTypeReference(FunctionTypeReference reference, Visiting visiting) { if (reference.isResolved() && reference.isOwnedBy(getOwner())) return reference; FunctionTypeReference result = getOwner().newFunctionTypeReference(reference.getType()); enhanceFunctionType(reference, result, visiting); return result; }
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; }
@Override protected LightweightTypeReference doVisitInnerFunctionTypeReference(InnerFunctionTypeReference reference, Visiting visiting) { if (reference.isResolved() && reference.isOwnedBy(getOwner())) return reference; LightweightTypeReference outer = reference.getOuter().accept(this, visiting); InnerFunctionTypeReference result = getOwner().newFunctionTypeReference(outer, reference.getType()); enhanceFunctionType(reference, result, visiting); return result; }
protected FunctionTypeReference initKnownClosureType(JvmType type, final JvmOperation operation) { ITypeReferenceOwner owner = getExpectation().getReferenceOwner(); FunctionTypeReference result = owner.newFunctionTypeReference(type); TypeParameterByUnboundSubstitutor substitutor = new TypeParameterByUnboundSubstitutor( Collections.<JvmTypeParameter, LightweightMergedBoundTypeArgument> emptyMap(), owner) {