@@ -270,7 +270,7 @@ public void createNames(HashSet<String> parentNames) {
270270
271271 @ SuppressWarnings ("unchecked" )
272272 public void updateLocalVariableInForStatements (TypeMaker typeMaker ) {
273- // Recursive call
273+ // Recursive call first
274274 if (children != null ) {
275275 for (Frame child : children ) {
276276 child .updateLocalVariableInForStatements (typeMaker );
@@ -366,7 +366,6 @@ protected void createNewLocalVariable(CreateLocalVariableVisitor createLocalVari
366366 AbstractLocalVariable newLV = createLocalVariableVisitor .getLocalVariable ();
367367
368368 newLV .setToOffset (toOffset , true );
369- newLV .setName (lv .getName ());
370369 addLocalVariable (newLV );
371370 Iterator <LocalVariableReference > iteratorLVR = lv .getReferences ().iterator ();
372371
@@ -641,7 +640,6 @@ protected void updateForStatement(
641640 if (!expression .isBinaryOperatorExpression ()) {
642641 return ;
643642 }
644-
645643 if (!expression .getLeftExpression ().isLocalVariableReferenceExpression ()) {
646644 return ;
647645 }
@@ -659,16 +657,28 @@ protected void updateForStatement(
659657 } else {
660658 Type type2 = localVariable .getType ();
661659
662- if (!type1 .equals (type2 ) && !type0 .equals (type2 .createType (0 ))) {
660+ if (type1 .isPrimitiveType () && type2 .isPrimitiveType ()) {
661+ Type type = PrimitiveTypeUtil .getCommonPrimitiveType ((PrimitiveType )type1 , (PrimitiveType )type2 );
662+
663+ if (type == null ) {
664+ return ;
665+ }
666+
667+ type0 = type ;
668+ type1 = type .createType (type1 .getDimension ());
669+ type2 = type .createType (type2 .getDimension ());
670+ } else if (!type1 .equals (type2 ) && !type0 .equals (type2 .createType (0 ))) {
663671 return ;
664672 }
665673
666674 int dimension = type2 .getDimension ();
667675
668- if (minDimension > dimension )
676+ if (minDimension > dimension ) {
669677 minDimension = dimension ;
670- if (maxDimension < dimension )
678+ }
679+ if (maxDimension < dimension ) {
671680 maxDimension = dimension ;
681+ }
672682 }
673683
674684 localVariables .add (localVariable );
@@ -803,20 +813,33 @@ protected void mergeDeclarations() {
803813 lineNumber1 = lineNumber2 ;
804814
805815 Type type2 = lvds2 .getType ();
806- int dimension = type2 .getDimension ();
807816
808- if (type1 .equals (type2 )) {
809- declarations .add (lvds2 );
810- } else if (type0 .equals (type2 .createType (0 ))) {
811- if (minDimension > dimension )
812- minDimension = dimension ;
813- if (maxDimension < dimension )
814- maxDimension = dimension ;
815- declarations .add (lvds2 );
816- } else {
817+ if (type1 .isPrimitiveType () && type2 .isPrimitiveType ()) {
818+ Type type = PrimitiveTypeUtil .getCommonPrimitiveType ((PrimitiveType )type1 , (PrimitiveType )type2 );
819+
820+ if (type == null ) {
821+ iterator .previous ();
822+ break ;
823+ }
824+
825+ type0 = type ;
826+ type1 = type .createType (type1 .getDimension ());
827+ type2 = type .createType (type2 .getDimension ());
828+ } else if (!type1 .equals (type2 ) && !type0 .equals (type2 .createType (0 ))) {
817829 iterator .previous ();
818830 break ;
819831 }
832+
833+ int dimension = type2 .getDimension ();
834+
835+ if (minDimension > dimension ) {
836+ minDimension = dimension ;
837+ }
838+ if (maxDimension < dimension ) {
839+ maxDimension = dimension ;
840+ }
841+
842+ declarations .add (lvds2 );
820843 }
821844
822845 int declarationSize = declarations .size ();
0 commit comments