]> source.dussan.org Git - javassist.git/commitdiff
fixed a bug of the compiler
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Thu, 23 Jun 2005 16:47:14 +0000 (16:47 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Thu, 23 Jun 2005 16:47:14 +0000 (16:47 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@185 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/compiler/CodeGen.java

index 10def2e603157a9e55904512195f2079293fa76a..fe74e281f1a392bb8c0ced5a73b17928f36289c3 100644 (file)
@@ -1077,6 +1077,8 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId {
         if (op == EQ) {         // ==, !=, ...
             BinExpr bexpr = (BinExpr)expr;
             int type1 = compileOprands(bexpr);
+            // here, arrayDim might represent the array dim. of the left oprand
+            // if the right oprand is NULL.
             compareExpr(branchIf, bexpr.getOperator(), type1, bexpr);
         }
         else if (op == '!')
@@ -1143,8 +1145,11 @@ public abstract class CodeGen extends Visitor implements Opcode, TokenId {
         int type1 = exprType;
         int dim1 = arrayDim;
         expr.oprand2().accept(this);
-        if (dim1 != arrayDim && type1 != NULL && exprType != NULL)
-            throw new CompileError("incompatible array types");
+        if (dim1 != arrayDim)
+            if (type1 != NULL && exprType != NULL)
+                throw new CompileError("incompatible array types");
+            else if (exprType == NULL)
+                arrayDim = dim1;
 
         if (type1 == NULL)
             return exprType;