Program: 102045
Project: 102045
Buggy source:
/** 
 * Find possible matches based on implicit conversions of the arguments. NOTE: This method has the side-effect of explicitly inserting conversions into the function arguments, and thereby changing the structure of the function call.
 * @param library
 * @param function
 * @param types
 * @return
 * @throws Exception 
 * @since 4.3
 */
private List<FunctionDescriptor> findWithImplicitConversions(FunctionLibrary library,Function function,Expression[] args,Class<?>[] types,boolean hasArgWithoutType) throws Exception {
  ConversionResult cr=library.determineNecessaryConversions(function.getName(),function.getType(),args,types,hasArgWithoutType);
  if (cr.method == null) {
    return Collections.emptyList();
  }
  Class<?>[] newSignature=types;
  if (cr.needsConverion) {
    FunctionDescriptor[] conversions=library.getConverts(cr.method,types);
    newSignature=new Class[conversions.length];
    for (int i=0; i < conversions.length; i++) {
      Class<?> newType=types[i];
      if (conversions[i] != null) {
        newType=conversions[i].getReturnType();
        setDesiredType(args[i],newType,function);
        if (types[i] != null && newType != DefaultDataTypes.OBJECT.getTypeClass()) {
          function.insertConversion(i,conversions[i]);
        }
      }
      newSignature[i]=newType;
    }
  }
  String name=cr.method.getFullName();
  return library.findAllFunctions(name,newSignature);
}

Fixed version (ground truth):
/** 
 * Find possible matches based on implicit conversions of the arguments. NOTE: This method has the side-effect of explicitly inserting conversions into the function arguments, and thereby changing the structure of the function call.
 * @param library
 * @param function
 * @param types
 * @return
 * @throws Exception 
 * @since 4.3
 */
private List<FunctionDescriptor> findWithImplicitConversions(FunctionLibrary library,Function function,Expression[] args,Class<?>[] types,boolean hasArgWithoutType) throws Exception {
  ConversionResult cr=null;
  try {
    cr=library.determineNecessaryConversions(function.getName(),function.getType(),args,types,hasArgWithoutType);
  }
 catch (  Exception ex) {
    if (getTeiidVersion().isLessThan(TeiidServerVersion.Version.TEIID_8_9.get()))     return Collections.emptyList();
 else     throw ex;
  }
  if (cr.method == null && getTeiidVersion().isGreaterThanOrEqualTo(TeiidServerVersion.Version.TEIID_8_9.get())) {
    return Collections.emptyList();
  }
  Class<?>[] newSignature=types;
  if (cr.needsConverion) {
    FunctionDescriptor[] conversions=library.getConverts(cr.method,types);
    newSignature=new Class[conversions.length];
    for (int i=0; i < conversions.length; i++) {
      Class<?> newType=types[i];
      if (conversions[i] != null) {
        newType=conversions[i].getReturnType();
        setDesiredType(args[i],newType,function);
        if (types[i] != null && newType != DefaultDataTypes.OBJECT.getTypeClass()) {
          function.insertConversion(i,conversions[i]);
        }
      }
      newSignature[i]=newType;
    }
  }
  String name=cr.method != null && cr.method.getFullName() != null ? cr.method.getFullName() : function.getName();
  return library.findAllFunctions(name,newSignature);
}