View | Details | Raw Unified | Return to bug 343621 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java (-2 / +6 lines)
Lines 215-221 Link Here
215
			CategorizedProblem[] problems = this.compilationResult.problems;
215
			CategorizedProblem[] problems = this.compilationResult.problems;
216
			int problemCount = this.compilationResult.problemCount;
216
			int problemCount = this.compilationResult.problemCount;
217
			for (int i = 0; i < problemCount; i++) {
217
			for (int i = 0; i < problemCount; i++) {
218
				if (problems[i].getID() == IProblem.LocalVariableIsNeverUsed) {
218
				CategorizedProblem currentProblem = problems[i];
219
				if (currentProblem.getID() == IProblem.LocalVariableIsNeverUsed
220
						&& currentProblem.isWarning()) {
219
					problems[i] = null;
221
					problems[i] = null;
220
					removed++;
222
					removed++;
221
				}
223
				}
Lines 299-305 Link Here
299
	if (remainingErrors > 0) {
301
	if (remainingErrors > 0) {
300
		for (int i = 0; i < problemCount; i++) {
302
		for (int i = 0; i < problemCount; i++) {
301
			CategorizedProblem problem;
303
			CategorizedProblem problem;
302
			if ((problem = problems[i]) != null && problem.getID() == IProblem.LocalVariableIsNeverUsed) {
304
			if ((problem = problems[i]) != null
305
					&& problem.getID() == IProblem.LocalVariableIsNeverUsed
306
					&& problem.isWarning()) {
303
				problems[i] = null;
307
				problems[i] = null;
304
				removed++;
308
				removed++;
305
			}
309
			}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/LocalVariableTest.java (-1 / +27 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 714-719 Link Here
714
		// javac options
714
		// javac options
715
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
715
		JavacTestOptions.Excuse.EclipseWarningConfiguredAsError /* javac test options */);
716
}
716
}
717
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=343621
718
public void test021() {
719
	Map options = getCompilerOptions();
720
	options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.ERROR);
721
	runNegativeTest(
722
		new String[] { /* test files */
723
			"X.java",
724
			"public class X {\n" + 
725
			"	public Object[] foo() {\n" + 
726
			"		Object[] i, j= new Object[0];\n" + 
727
			"		i= j = null;\n" + 
728
			"		i= (new Object[] { null, null });\n" + 
729
			"		return j;\n" + 
730
			"	}\n" + 
731
			"}", // =================
732
		},
733
		"----------\n" + 
734
		"1. ERROR in X.java (at line 3)\n" + 
735
		"	Object[] i, j= new Object[0];\n" + 
736
		"	         ^\n" + 
737
		"The value of the local variable i is not used\n" + 
738
		"----------\n",
739
		null /* no class libraries */,
740
		true,
741
		options /* custom options */);
742
}
717
public static Class testClass() {
743
public static Class testClass() {
718
	return LocalVariableTest.class;
744
	return LocalVariableTest.class;
719
}
745
}

Return to bug 343621