Skip to content

Commit 5548877

Browse files
committed
Missing types Byte and Short added to the operator; Added exception on incompatible types
1 parent 0e49b76 commit 5548877

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/mujava/op/CRCR.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ private List<Expression> getMutations(UnaryExpression from) throws ParseTreeExce
5656
boolean isZero = isZero(from.getExpression());
5757
boolean isOne = isOne(from.getExpression());
5858
UnaryExpression originalCopy = (UnaryExpression) from.makeRecursiveCopy_keepOriginalID();
59-
if (compatibleAssignTypeStrict(OJClass.forClass(Integer.class), exprType, true)) {
59+
if (compatibleAssignTypeStrict(OJClass.forClass(Integer.class), exprType, true)
60+
|| compatibleAssignTypeStrict(OJClass.forClass(Byte.class), exprType, true)
61+
|| compatibleAssignTypeStrict(OJClass.forClass(Short.class), exprType, true))
62+
{
6063
if (!(isZero && (isNeg || isPlus))) {
6164
expressions.add(Literal.makeLiteral(new Integer(0)));
6265
}
@@ -115,6 +118,8 @@ private List<Expression> getMutations(UnaryExpression from) throws ParseTreeExce
115118
mutMinusOne.forceParenthesis(true);
116119
expressions.add(mutPlusOne);
117120
expressions.add(mutMinusOne);
121+
} else {
122+
throw new ParseTreeException("getMutations called with incompatible type");
118123
}
119124
if (!isZero) expressions.add(new UnaryExpression(originalCopy, UnaryExpression.MINUS));
120125
return expressions;

0 commit comments

Comments
 (0)