Code review comment: agg_state, variant could cast to json? what we will get if cast ipv4 /ipv6 to json.

Code before review:
public static boolean canCastTo(Type sourceType, Type targetType) {
if (targetType.isJsonbType()) {
return true;
}
if (sourceType.isVariantType() && (targetType.isScalarType() || targetType.isArrayType())) {
return true;
} else if (sourceType.isScalarType() && targetType.isScalarType()) {
return ScalarType.canCastTo((ScalarType) sourceType, (ScalarType) targetType);
} else if (sourceType.isArrayType() && targetType.isArrayType()) {
return ArrayType.canCastTo((ArrayType) sourceType, (ArrayType) targetType);
} else if (sourceType.isMapType() && targetType.isMapType()) {
return MapType.canCastTo((MapType) sourceType, (MapType) targetType);
} else if (targetType.isArrayType() && !((ArrayType) targetType).getItemType().isScalarType()
&& !sourceType.isNull() && !sourceType.isStringType()) {
return false;
} else if ((targetType.isStructType() || targetType.isMapType()) && sourceType.isStringType()) {
return true;
} else if (sourceType.isStructType() && targetType.isStructType()) {
return StructType.canCastTo((StructType) sourceType, (StructType) targetType);
} else if (sourceType.isAggStateType() && targetType.getPrimitiveType().isCharFamily()) {
return true;
} else if (sourceType.isAggStateType() && targetType.isAggStateType()) {
AggStateType sourceAggState = (AggStateType) sourceType;
AggStateType targetAggState = (AggStateType) targetType;
if (!sourceAggState.getFunctionName().equalsIgnoreCase(targetAggState.getFunctionName())) {
return false;
}
if (sourceAggState.getSubTypes().size() != targetAggState.getSubTypes().size()) {
return false;
}
for (int i = 0; i < sourceAggState.getSubTypes().size(); i++) {
if (!targetAggState.getSubTypeNullables().get(i) && sourceAggState.getSubTypeNullables().get(i)) {
return false;
}
if (!canCastTo(sourceAggState.getSubTypes().get(i), targetAggState.getSubTypes().get(i))) {
return false;
}
}
return true;
}
return sourceType.isNull() || sourceType.getPrimitiveType().isCharFamily();
}

Line under review: return true;

Code after addressing the review:
public static boolean canCastTo(Type sourceType, Type targetType) {
if (targetType.isJsonbType() && sourceType.isComplexType()) {
return true;
}
if (sourceType.isVariantType() && (targetType.isScalarType() || targetType.isArrayType())) {
return true;
} else if (sourceType.isScalarType() && targetType.isScalarType()) {
return ScalarType.canCastTo((ScalarType) sourceType, (ScalarType) targetType);
} else if (sourceType.isArrayType() && targetType.isArrayType()) {
return ArrayType.canCastTo((ArrayType) sourceType, (ArrayType) targetType);
} else if (sourceType.isMapType() && targetType.isMapType()) {
return MapType.canCastTo((MapType) sourceType, (MapType) targetType);
} else if (targetType.isArrayType() && !((ArrayType) targetType).getItemType().isScalarType()
&& !sourceType.isNull() && !sourceType.isStringType()) {
return false;
} else if ((targetType.isStructType() || targetType.isMapType()) && sourceType.isStringType()) {
return true;
} else if (sourceType.isStructType() && targetType.isStructType()) {
return StructType.canCastTo((StructType) sourceType, (StructType) targetType);
} else if (sourceType.isAggStateType() && targetType.getPrimitiveType().isCharFamily()) {
return true;
} else if (sourceType.isAggStateType() && targetType.isAggStateType()) {
AggStateType sourceAggState = (AggStateType) sourceType;
AggStateType targetAggState = (AggStateType) targetType;
if (!sourceAggState.getFunctionName().equalsIgnoreCase(targetAggState.getFunctionName())) {
return false;
}
if (sourceAggState.getSubTypes().size() != targetAggState.getSubTypes().size()) {
return false;
}
for (int i = 0; i < sourceAggState.getSubTypes().size(); i++) {
if (!targetAggState.getSubTypeNullables().get(i) && sourceAggState.getSubTypeNullables().get(i)) {
return false;
}
if (!canCastTo(sourceAggState.getSubTypes().get(i), targetAggState.getSubTypes().get(i))) {
return false;
}
}
return true;
}
return sourceType.isNull() || sourceType.getPrimitiveType().isCharFamily();
}