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); }