else
insertCast(expr, type1, type2);
- if (CodeGen.isP_INT(exprType))
+ if (CodeGen.isP_INT(exprType) && exprType != BOOLEAN)
exprType = INT; // type1 may be BYTE, ...
}
Object obj = make(cc.getName());
assertEquals(0, invoke(obj, "say"));
}
+
+ public void testJIRA249() throws Exception {
+ CtClass cc = sloader.get("test5.BoolTest");
+ CtMethod testMethod = cc.getDeclaredMethod("test");
+ testMethod.insertBefore("i = foo(true & true);");
+ cc.writeFile();
+ Object obj = make(cc.getName());
+ assertEquals(1, invoke(obj, "run"));
+ }
}
--- /dev/null
+package test5;
+
+public class BoolTest {
+ static boolean i = false;
+ public boolean test() {
+ return i;
+ }
+ public boolean foo(boolean b) { return b; }
+ public int run() {
+ if (test())
+ return 1;
+ else
+ return 0;
+ }
+}