From 4e22d9605332d97c4d6674ffb311de93f8000981 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Fri, 30 Nov 2018 18:33:08 +0300 Subject: [PATCH] fix for IDEA-CR-40723 --- .../expression/TypeCastEvaluator.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/TypeCastEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/TypeCastEvaluator.java index 46c6044afd59..52ec73df165e 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/TypeCastEvaluator.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/TypeCastEvaluator.java @@ -19,18 +19,18 @@ import org.jetbrains.annotations.NotNull; public class TypeCastEvaluator implements Evaluator { private final Evaluator myOperandEvaluator; - private final String myCastType; + private final String myPrimitiveCastType; private final TypeEvaluator myTypeCastEvaluator; public TypeCastEvaluator(Evaluator operandEvaluator, @NotNull TypeEvaluator typeCastEvaluator) { myOperandEvaluator = operandEvaluator; - myCastType = null; + myPrimitiveCastType = null; myTypeCastEvaluator = typeCastEvaluator; } public TypeCastEvaluator(Evaluator operandEvaluator, @NotNull String primitiveType) { myOperandEvaluator = operandEvaluator; - myCastType = primitiveType; + myPrimitiveCastType = primitiveType; myTypeCastEvaluator = null; } @@ -38,41 +38,44 @@ public class TypeCastEvaluator implements Evaluator { public Object evaluate(EvaluationContextImpl context) throws EvaluateException { Value value = (Value)myOperandEvaluator.evaluate(context); if (value == null) { - if (myCastType != null) { - throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.null", myCastType)); + if (myPrimitiveCastType != null) { + throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.null", myPrimitiveCastType)); } return null; } VirtualMachineProxyImpl vm = context.getDebugProcess().getVirtualMachineProxy(); if (DebuggerUtils.isInteger(value)) { - value = DebuggerUtilsEx.createValue(vm, myCastType, ((PrimitiveValue)value).longValue()); + value = DebuggerUtilsEx.createValue(vm, myPrimitiveCastType, ((PrimitiveValue)value).longValue()); if (value == null) { - throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.numeric", myCastType)); + throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.numeric", + myPrimitiveCastType)); } } else if (DebuggerUtils.isNumeric(value)) { - value = DebuggerUtilsEx.createValue(vm, myCastType, ((PrimitiveValue)value).doubleValue()); + value = DebuggerUtilsEx.createValue(vm, myPrimitiveCastType, ((PrimitiveValue)value).doubleValue()); if (value == null) { - throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.numeric", myCastType)); + throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.numeric", + myPrimitiveCastType)); } } else if (value instanceof BooleanValue) { - value = DebuggerUtilsEx.createValue(vm, myCastType, ((BooleanValue)value).booleanValue()); + value = DebuggerUtilsEx.createValue(vm, myPrimitiveCastType, ((BooleanValue)value).booleanValue()); if (value == null) { - throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.boolean", myCastType)); + throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.boolean", + myPrimitiveCastType)); } } else if (value instanceof CharValue) { - value = DebuggerUtilsEx.createValue(vm, myCastType, ((CharValue)value).charValue()); + value = DebuggerUtilsEx.createValue(vm, myPrimitiveCastType, ((CharValue)value).charValue()); if (value == null) { - throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.char", myCastType)); + throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.cannot.cast.char", myPrimitiveCastType)); } } else if (value instanceof ObjectReference) { ReferenceType type = ((ObjectReference)value).referenceType(); if (myTypeCastEvaluator == null) { throw EvaluateExceptionUtil.createEvaluateException( - DebuggerBundle.message("evaluation.error.cannot.cast.object", type.name(), myCastType)); + DebuggerBundle.message("evaluation.error.cannot.cast.object", type.name(), myPrimitiveCastType)); } ReferenceType castType = (ReferenceType)myTypeCastEvaluator.evaluate(context); if (!DebuggerUtilsImpl.instanceOf(type, castType)) {