types[0] = type;
hasArgWithoutType = false;
}
// Attempt to get exact match of function for this signature
FunctionDescriptor fd = findWithImplicitConversions(library, function, args, types, hasArgWithoutType);
// Function did not resolve - determine reason and throw exception
if(fd == null) {
FunctionForm form = library.findFunctionForm(function.getName(), args.length);
if(form == null) {
// Unknown function form
throw new QueryResolverException("ERR.015.008.0039", QueryPlugin.Util.getString("ERR.015.008.0039", function)); //$NON-NLS-1$ //$NON-NLS-2$
}
// Known function form - but without type information
if (hasArgWithoutType) {
throw new QueryResolverException("ERR.015.008.0036", QueryPlugin.Util.getString("ERR.015.008.0036", function)); //$NON-NLS-1$ //$NON-NLS-2$
}
// Known function form - unable to find implicit conversions
throw new QueryResolverException("ERR.015.008.0040", QueryPlugin.Util.getString("ERR.015.008.0040", function)); //$NON-NLS-1$ //$NON-NLS-2$
}
if(fd.getName().equalsIgnoreCase(FunctionLibrary.CONVERT) || fd.getName().equalsIgnoreCase(FunctionLibrary.CAST)) {
String dataType = (String) ((Constant)args[1]).getValue();
Class dataTypeClass = DataTypeManager.getDataTypeClass(dataType);
fd = library.findTypedConversionFunction(args[0].getType(), dataTypeClass);
// Verify that the type conversion from src to type is even valid
Class srcTypeClass = args[0].getType();
if(srcTypeClass != null && dataTypeClass != null &&
!srcTypeClass.equals(dataTypeClass) &&
!DataTypeManager.isTransformable(srcTypeClass, dataTypeClass)) {
throw new QueryResolverException("ERR.015.008.0037", QueryPlugin.Util.getString("ERR.015.008.0037", new Object[] {DataTypeManager.getDataTypeName(srcTypeClass), dataType})); //$NON-NLS-1$ //$NON-NLS-2$
}
} else if(fd.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)) {
ResolverUtil.ResolvedLookup lookup = ResolverUtil.resolveLookup(function, metadata);
fd = library.copyFunctionChangeReturnType(fd, lookup.getReturnElement().getType());
}
// Resolve the function
function.setFunctionDescriptor(fd);
function.setType(fd.getReturnType());
}