View | Details | Raw Unified | Return to bug 301405
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java (-1 / +3 lines)
Lines 862-868 Link Here
862
			// check whether comparing identical expressions
862
			// check whether comparing identical expressions
863
			Binding leftDirect = Expression.getDirectBinding(this.left);
863
			Binding leftDirect = Expression.getDirectBinding(this.left);
864
			if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) {
864
			if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) {
865
				if (!(this.right instanceof Assignment)) {
865
				int leftTypeID = leftType.id;
866
				if (leftTypeID != TypeIds.T_JavaLangFloat && leftTypeID != TypeIds.T_JavaLangDouble  &&  // https://bugs.eclipse.org/bugs/show_bug.cgi?id=301405
867
						(!(this.right instanceof Assignment))) {
866
					scope.problemReporter().comparingIdenticalExpressions(this);
868
					scope.problemReporter().comparingIdenticalExpressions(this);
867
				}
869
				}
868
			}
870
			}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java (+28 lines)
Lines 1928-1933 Link Here
1928
		options
1928
		options
1929
	);
1929
	);
1930
}
1930
}
1931
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=301405
1932
public void test068() {
1933
	Map options = getCompilerOptions();
1934
	options.put(CompilerOptions.OPTION_ReportComparingIdentical, CompilerOptions.ERROR);
1935
	this.runNegativeTest(
1936
		new String[] {
1937
			"X.java",
1938
			"public class X {\n" +
1939
			"	public boolean test(Float f) {\n" +
1940
			"       return f != f;\n" + 
1941
			"	}\n" +
1942
			"	public boolean test(Double f) {\n" +
1943
			"       return f != f;\n" + 
1944
			"	}\n" +
1945
			"   Zork z;\n" +
1946
			"}"
1947
		},
1948
		"----------\n" + 
1949
		"1. ERROR in X.java (at line 8)\n" + 
1950
		"	Zork z;\n" + 
1951
		"	^^^^\n" + 
1952
		"Zork cannot be resolved to a type\n" + 
1953
		"----------\n",
1954
		null,
1955
		true,
1956
		options
1957
	);
1958
}
1931
public static Class testClass() {
1959
public static Class testClass() {
1932
	return AssignmentTest.class;
1960
	return AssignmentTest.class;
1933
}
1961
}

Return to bug 301405