Fix incorrect TypeCastException message when casting null

#KT-5121 Fixed
This commit is contained in:
Alexander Udalov
2015-07-04 03:18:50 +03:00
parent cb03f0df5a
commit ac0db5ce80
2 changed files with 19 additions and 8 deletions
@@ -3727,7 +3727,7 @@ The "returned" value of try expression with no finally is either the last expres
@Override
public StackValue visitBinaryWithTypeRHSExpression(@NotNull JetBinaryExpressionWithTypeRHS expression, StackValue receiver) {
final JetExpression left = expression.getLeft();
JetExpression left = expression.getLeft();
final IElementType opToken = expression.getOperationReference().getReferencedNameElementType();
if (opToken == JetTokens.COLON) {
return gen(left);
@@ -3752,10 +3752,7 @@ The "returned" value of try expression with no finally is either the last expres
v.dup();
Label nonnull = new Label();
v.ifnonnull(nonnull);
JetType leftType = bindingContext.getType(left);
assert leftType != null;
genThrow(v, "kotlin/TypeCastException", DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(leftType) +
" cannot be cast to " +
genThrow(v, "kotlin/TypeCastException", "null cannot be cast to non-null type " +
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(rightType));
v.mark(nonnull);
}