]> source.dussan.org Git - javassist.git/commitdiff
fixed JIRA JASSIST-249
authorchibash <chiba@javassist.org>
Wed, 15 Jul 2015 06:45:22 +0000 (15:45 +0900)
committerchibash <chiba@javassist.org>
Wed, 15 Jul 2015 06:45:22 +0000 (15:45 +0900)
src/main/javassist/compiler/TypeChecker.java
src/test/javassist/JvstTest5.java
src/test/test5/BoolTest.java [new file with mode: 0644]

index d28146268e3482dfaf04bd1ce5885b3dc331f775..bd62f80659d7fad2167d97ef531826a7d59e8939 100644 (file)
@@ -502,7 +502,7 @@ public class TypeChecker extends Visitor implements Opcode, TokenId {
         else
             insertCast(expr, type1, type2);
 
-        if (CodeGen.isP_INT(exprType))
+        if (CodeGen.isP_INT(exprType) && exprType != BOOLEAN)
             exprType = INT;         // type1 may be BYTE, ...
     }
 
index fcbbbb9957836f8e1f518217dc9a4c6b27c1d7cd..cefc84fc6b37f00644b6a553b174ef9a2986e4f1 100644 (file)
@@ -91,4 +91,13 @@ public class JvstTest5 extends JvstTestRoot {
         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"));
+    }
 }
diff --git a/src/test/test5/BoolTest.java b/src/test/test5/BoolTest.java
new file mode 100644 (file)
index 0000000..0d9ca15
--- /dev/null
@@ -0,0 +1,15 @@
+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;
+    }
+}