@@ -529,6 +529,7 @@ public boolean visit(EnhancedForStatement node) {
529529
530530 /**
531531 * allow for primitive boxing or unboxing. See test.Test_Chars.java
532+ *
532533 * @param template
533534 * @param v
534535 * @param varName
@@ -538,19 +539,24 @@ public boolean visit(EnhancedForStatement node) {
538539 private void writeReplaceV (String template , String v , String varName , ITypeBinding vType , ITypeBinding eType ) {
539540 String s = template .replace (v , varName );
540541 if (vType != eType ) {
541- if (!eType .isPrimitive ()) {
542- // So we know the expression is boxed -- Character, for example
543- // Character does not use .objectValue, but we implement it here
544- s += ".objectValue()" ;
545- if (vType .getName ().equals ("int" ))
542+ if (vType .isPrimitive ()) {
543+ if (eType .isPrimitive ()) {
544+ // this is a conversion of an char[] to an int -- the only
545+ // possibility allowed, I think
546546 s += CHARCODEAT0 ;
547- } else if (!vType .isPrimitive ()) {
547+ } else {
548+ // So we know the expression is boxed -- Character, for
549+ // example
550+ // Character does not use .objectValue, but we implement it
551+ // here
552+ if (vType .getName ().equals ("int" ))
553+ s += ".intValue()" ;
554+ else
555+ s += ".objectValue()" ;
556+ }
557+ } else if (eType .isPrimitive ()) {
548558 // So we know the expression is unboxed -- char, for example
549- // but it could be Character to int
550559 s = "new " + getPrimitiveTYPE (eType .getName ()) + s ;
551- } else {
552- // this is a conversion of an char[] to an int -- the only possibility allowed, I think
553- s += CHARCODEAT0 ;
554560 }
555561 }
556562 buffer .append (s );
0 commit comments