### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java,v retrieving revision 1.50 diff -u -r1.50 ForeachStatement.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 27 Jun 2008 16:03:55 -0000 1.50 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 28 Aug 2008 18:56:23 -0000 @@ -373,7 +373,11 @@ printIndent(indent, output).append("for ("); //$NON-NLS-1$ this.elementVariable.printAsExpression(0, output); output.append(" : ");//$NON-NLS-1$ - this.collection.print(0, output).append(") "); //$NON-NLS-1$ + if (this.collection != null) { + this.collection.print(0, output).append(") "); //$NON-NLS-1$ + } else { + output.append(')'); + } //block if (this.action == null) { output.append(';'); @@ -525,7 +529,9 @@ if (visitor.visit(this, blockScope)) { this.elementVariable.traverse(visitor, this.scope); - this.collection.traverse(visitor, this.scope); + if (this.collection != null) { + this.collection.traverse(visitor, this.scope); + } if (this.action != null) { this.action.traverse(visitor, this.scope); } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v retrieving revision 1.275 diff -u -r1.275 ASTConverter15Test.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 20 Aug 2008 11:55:44 -0000 1.275 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 28 Aug 2008 18:56:26 -0000 @@ -46,7 +46,7 @@ } static { -// TESTS_NUMBERS = new int[] { 322 }; +// TESTS_NUMBERS = new int[] { 323 }; // TESTS_RANGE = new int[] { 308, -1 }; // TESTS_NAMES = new String[] {"test0204"}; } @@ -10342,4 +10342,31 @@ IMemberValuePairBinding pairBinding = memberValuePairBindings[0]; assertNull("Got a value", pairBinding.getValue()); } + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=245563 + */ + public void test0323() throws JavaModelException { + String contents = + "class X {\n" + + " {\n" + + " for(Object obj:\n" + + " new Object[]{\n" + + " new Object(){\n" + + " int field=method(\n" + + " });\n" + + " }\n" + + " });\n" + + " }\n" + + " int method(int...args){\n" + + " return args.length;\n" + + " }\n" + + "}\n" + + ""; + this.workingCopy = getWorkingCopy( + "/Converter15/src/test0322/X.java", + contents, + true/*resolve*/ + ); + assertNotNull("No node", buildAST(contents, workingCopy, false, true, true)); + } } \ No newline at end of file