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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 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 104-109 Link Here
104
	}
104
	}
105
105
106
	public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
106
	public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
107
		if (!valueRequired)
108
			currentScope.problemReporter().unusedObjectAllocation(this);
107
		int pc = codeStream.position;
109
		int pc = codeStream.position;
108
		MethodBinding codegenBinding = this.binding.original();
110
		MethodBinding codegenBinding = this.binding.original();
109
		ReferenceBinding allocatedType = codegenBinding.declaringClass;
111
		ReferenceBinding allocatedType = codegenBinding.declaringClass;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java (-3 / +29 lines)
Lines 27-33 Link Here
27
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
27
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
28
28
29
public class FlowAnalysisTest extends AbstractRegressionTest {
29
public class FlowAnalysisTest extends AbstractRegressionTest {
30
30
static {
31
//	TESTS_NUMBERS = new int[] { 69 };
32
}
31
public FlowAnalysisTest(String name) {
33
public FlowAnalysisTest(String name) {
32
	super(name);
34
	super(name);
33
}
35
}
Lines 2069-2075 Link Here
2069
		true /* shouldFlushOutputDirectory */,
2071
		true /* shouldFlushOutputDirectory */,
2070
		compilerOptions);
2072
		compilerOptions);
2071
}
2073
}
2072
2073
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385
2074
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385
2074
// warning suppressed
2075
// warning suppressed
2075
public void test065() {
2076
public void test065() {
Lines 2160-2166 Link Here
2160
		compilerOptions /* customOptions */,
2161
		compilerOptions /* customOptions */,
2161
		null /* clientRequestor */);
2162
		null /* clientRequestor */);
2162
}
2163
}
2163
2164
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=236385
2165
//anonymous type
2166
public void test069() {
2167
	Map compilerOptions = getCompilerOptions();
2168
	compilerOptions.put(CompilerOptions.OPTION_ReportUnusedObjectAllocation, CompilerOptions.ERROR);
2169
	runNegativeTest(
2170
		new String[] {
2171
			"X.java",
2172
			"public class X {\n" +
2173
			"   boolean bar() { return false; } \n" +
2174
			"	public void foo() {" +
2175
			"		if (bar())\n" +
2176
			"			new Object() {};\n" +
2177
			"	}\n" +
2178
			"}",
2179
		},
2180
		"----------\n" + 
2181
		"1. ERROR in X.java (at line 4)\n" + 
2182
		"	new Object() {};\n" + 
2183
		"	^^^^^^^^^^^^^^^\n" + 
2184
		"The allocated object is never used\n" + 
2185
		"----------\n",
2186
		null /* classLibraries */,
2187
		true /* shouldFlushOutputDirectory */,
2188
		compilerOptions);
2189
}
2164
public static Class testClass() {
2190
public static Class testClass() {
2165
	return FlowAnalysisTest.class;
2191
	return FlowAnalysisTest.class;
2166
}
2192
}

Return to bug 236385