private void common(TypeInfo a, TypeInfo b, TypeInfo result) { assertEquals(result, FunctionRegistry.getCommonClass(a,b)); }
switch (conversionType) { case COMMON: commonTypeInfo = FunctionRegistry.getCommonClass(oiTypeInfo, rTypeInfo); break; case UNION:
/** * Find a common class that objects of both TypeInfo a and TypeInfo b can * convert to. This is used for places other than comparison. * * The common class of string and double is string. * * @return null if no common class could be found. */ public static TypeInfo getCommonClass(TypeInfo a, TypeInfo b) { if (a.equals(b)) { return a; } // We try to infer a common primitive category PrimitiveCategory commonCat = getPrimitiveCommonCategory(a, b); if (commonCat != null) { return getTypeInfoForPrimitiveCategory((PrimitiveTypeInfo)a, (PrimitiveTypeInfo)b, commonCat); } // It is not primitive; check if it is a struct and we can infer a common class if (a.getCategory() == Category.STRUCT && b.getCategory() == Category.STRUCT) { return getCommonClassForStruct((StructTypeInfo)a, (StructTypeInfo)b, (type1, type2) -> getCommonClass(type1, type2)); } return null; }
commonTypeInfo = FunctionRegistry.getCommonClassForUnionAll(rTypeInfo, oiTypeInfo); } else { commonTypeInfo = FunctionRegistry.getCommonClass(oiTypeInfo, rTypeInfo);
ArrayList<TypeInfo> toTypes = b.getAllStructFieldTypeInfos(); for (int i = 0; i < fromTypes.size(); i++) { TypeInfo commonType = getCommonClass(fromTypes.get(i), toTypes.get(i)); if (commonType == null) { return null;
rTypeInfo); } else { commonTypeInfo = FunctionRegistry.getCommonClass(oiTypeInfo, rTypeInfo);
TypeInfo commonType = FunctionRegistry.getCommonClass(modArgTypeInfos .get(0), modArgTypeInfos.get(1));
TypeInfo commonType = FunctionRegistry.getCommonClass(modArgTypeInfos .get(0), modArgTypeInfos.get(1));
public static TypeInfo deriveInType(List<ExprNodeDesc> children) { TypeInfo returnType = null; for (ExprNodeDesc node : children) { TypeInfo ti = node.getTypeInfo(); if (ti.getCategory() == Category.PRIMITIVE && ((PrimitiveTypeInfo)ti).getPrimitiveCategory() == PrimitiveCategory.VOID) { continue; } if (returnType == null) { returnType = ti; continue; } if (returnType == ti) continue; TypeInfo commonTypeInfo = FunctionRegistry.getCommonClass(returnType, ti); if (commonTypeInfo == null) return null; returnType = updateCommonTypeForDecimal(commonTypeInfo, ti, returnType); } return returnType; }
TypeInfo commonType = FunctionRegistry.getCommonClass(modArgTypeInfos .get(0), modArgTypeInfos.get(1));
TypeInfo commonType = FunctionRegistry.getCommonClass(modArgTypeInfos .get(0), modArgTypeInfos.get(1));
TypeInfo commonTypeInfo = FunctionRegistry.getCommonClass(oiTypeInfo, rTypeInfo); if (commonTypeInfo == null) {