if ((flags & ALLOW_FUNCTION_CONVERSION) == 0) return flags; FunctionTypeReference leftFunctionType = left.getAsFunctionTypeReference(); if (leftFunctionType != null) { FunctionTypeReference rightFunctionType = right.getAsFunctionTypeReference(); if (rightFunctionType != null) { return flags; FunctionTypeReference rightFunctionType = right.getAsFunctionTypeReference(); if (rightFunctionType != null) { leftFunctionType = left.tryConvertToFunctionTypeReference((flags & RAW_TYPE) != 0);
protected LightweightTypeReference doGetTypeParametersForSuperType( final Multimap<JvmType, LightweightTypeReference> all, JvmGenericType rawType, ITypeReferenceOwner owner, List<LightweightTypeReference> types) { // if we do not declare any parameters it is safe to return the first candidate if (!hasTypeParameters(rawType)) { return getFirstForRawType(all, rawType); } ParameterizedTypeReference result = owner.newParameterizedTypeReference(rawType); pushRequestedTypes(types); if (!enhanceSuperType(Lists.newArrayList(all.get(rawType)), result)) { return null; } FunctionTypeReference resultAsFunctionType = result.getAsFunctionTypeReference(); if (resultAsFunctionType != null) return resultAsFunctionType; return result; }
protected int doIsConformant(FunctionTypeReference left, ParameterizedTypeReference right, int flags) { if ((flags & ALLOW_FUNCTION_CONVERSION) == 0) return doIsConformant((ParameterizedTypeReference) left, right, flags); FunctionTypeReference convertedRight = right.getAsFunctionTypeReference(); if (convertedRight != null) { return doIsConformant(left, convertedRight, flags); } if (left.isFunctionType()) { convertedRight = right.tryConvertToFunctionTypeReference(false); if (convertedRight != null) { int result = doIsConformant(left, convertedRight, flags); if ((result & SUCCESS) != 0) { return result | DEMAND_CONVERSION; } } } return doIsConformant((ParameterizedTypeReference) left, right, flags); }
protected int doIsConformant(ParameterizedTypeReference left, FunctionTypeReference right, int flags) { if ((flags & ALLOW_FUNCTION_CONVERSION) == 0) return doIsConformant(left, (ParameterizedTypeReference) right, flags); // TODO don't convert if not necessary: // right.getType == left.getType -> doIsConformant optimized to function types -> declarator == procedure, ignore return type etc // next: get function type kind and arity of right and check against left if it is a function type // afterwards, do optimized check of left against the argument types of right FunctionTypeReference convertedLeft = left.getAsFunctionTypeReference(); if (convertedLeft != null) { return doIsConformant(convertedLeft, right, flags); } if (right.isFunctionType()) { // todo optimize tryConvertToFunctionTypeReference convertedLeft = left.tryConvertToFunctionTypeReference(false); if (convertedLeft != null) { int result = doIsConformant(convertedLeft, right, flags); if ((result & SUCCESS) != 0) { return result | DEMAND_CONVERSION; } } } return doIsConformant(left, (ParameterizedTypeReference) right, flags); }