/** * Determines the conversion type, taking lossiness into consideration for numeric conversions. * Returns {@link ConversionType#NONE} if a determination could not be made. */ private ConversionType getConversion( @NotNull final TypeReference target, @NotNull final TypeReference source, @Nullable final Expression value) { final TypeReference unboxedTarget = unbox(target); final TypeReference unboxedSource = unbox(source); if (unboxedTarget.getSimpleType().isNumeric() && unboxedSource.getSimpleType().isNumeric()) { return getNumericConversion(target, source, value); } return MetadataHelper.getConversionType(target, source); }
@Override public Void visitCastExpression(final CastExpression node, final Void data) { super.visitCastExpression(node, data); final Expression operand = node.getExpression(); final ResolveResult targetResult = _resolver.apply(node.getType()); if (targetResult == null || targetResult.getType() == null) { return null; } final ResolveResult valueResult = _resolver.apply(operand); if (valueResult == null || valueResult.getType() == null) { return null; } final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType()); if (conversionType == ConversionType.NONE) { addCastForAssignment(node.getType(), node.getExpression()); } if (RedundantCastUtility.isCastRedundant(_resolver, node)) { RedundantCastUtility.removeCast(node); } return null; }
@Override public Void visitCastExpression(final CastExpression node, final Void data) { super.visitCastExpression(node, data); final Expression operand = node.getExpression(); final ResolveResult targetResult = _resolver.apply(node.getType()); if (targetResult == null || targetResult.getType() == null) { return null; } final ResolveResult valueResult = _resolver.apply(operand); if (valueResult == null || valueResult.getType() == null) { return null; } final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType()); if (conversionType == ConversionType.NONE) { addCastForAssignment(node.getType(), node.getExpression()); } if (RedundantCastUtility.isCastRedundant(_resolver, node)) { RedundantCastUtility.removeCast(node); } return null; }
@Override public Void visitCastExpression(final CastExpression node, final Void data) { super.visitCastExpression(node, data); final Expression operand = node.getExpression(); final ResolveResult targetResult = _resolver.apply(node.getType()); if (targetResult == null || targetResult.getType() == null) { return null; } final ResolveResult valueResult = _resolver.apply(operand); if (valueResult == null || valueResult.getType() == null) { return null; } final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType()); if (conversionType == ConversionType.NONE) { addCastForAssignment(node.getType(), node.getExpression()); } if (RedundantCastUtility.isCastRedundant(_resolver, node)) { RedundantCastUtility.removeCast(node); } return null; }
MetadataHelper.getConversionType(unboxedType, rr.getType()).isImplicit()) {
final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType());
final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType());
final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType());
MetadataHelper.getConversionType(topCastType, innerOperandType) != ConversionType.NONE) {
MetadataHelper.getConversionType(topCastType, innerOperandType) != ConversionType.NONE) {
MetadataHelper.getConversionType(topCastType, innerOperandType).isDirect()) {