### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java,v retrieving revision 1.15 diff -u -r1.15 ASTConverterRecoveryTest.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java 28 Apr 2009 17:49:27 -0000 1.15 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java 25 May 2009 11:47:18 -0000 @@ -978,11 +978,15 @@ "===== Details =====\n" + "1:EMPTY_STATEMENT,[77,0],,RECOVERED,[N/A]\n" + "===== Problems =====\n" + - "1. ERROR in /Converter/src/p/X.java (at line 4)\n" + + "1. WARNING in /Converter/src/p/X.java (at line 4)\n" + + " if (1==1 && var.equals(1) {\n" + + " ^^^^\n" + + "Comparing identical expressions\n" + + "2. ERROR in /Converter/src/p/X.java (at line 4)\n" + " if (1==1 && var.equals(1) {\n" + " ^^^^^^\n" + "The method equals(Object) in the type Object is not applicable for the arguments (int)\n" + - "2. ERROR in /Converter/src/p/X.java (at line 4)\n" + + "3. ERROR in /Converter/src/p/X.java (at line 4)\n" + " if (1==1 && var.equals(1) {\n" + " ^\n" + "Syntax error, insert \") Statement\" to complete BlockStatements\n", #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java,v retrieving revision 1.15 diff -u -r1.15 ProgrammingProblemsTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 27 Jun 2008 16:04:46 -0000 1.15 +++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 25 May 2009 11:47:40 -0000 @@ -1399,4 +1399,134 @@ "Zork cannot be resolved to a type\n" + "----------\n"); } + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=276740" + */ +public void test0038() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public static void main(String[] args) {\n" + + " boolean b1 = 1 == 1;\n" + + " boolean b2 = 1 != 1;\n" + + " boolean b3 = 1 == 1.0;\n" + + " boolean b4 = 1 != 1.0;\n" + + " boolean b5 = 1 == 2;\n" + + " boolean b6 = 1 != 2;\n" + + " boolean b7 = 1 == 2.0;\n" + + " boolean b8 = 1 != 2.0;\n" + + " final short s1 = 1;\n" + + " final short s2 = 2;\n" + + " boolean b9 = 1 == s1;\n" + + " boolean b10 = 1 == s2;\n" + + " boolean b91 = 1 != s1;\n" + + " boolean b101 = 1 != s2;\n" + + " final long l1 = 1;\n" + + " final long l2 = 2;\n" + + " boolean b11 = 1 == l1;\n" + + " boolean b12 = 1 == l2;\n" + + " boolean b111 = 1 != l1;\n" + + " boolean b121 = 1 != l2;\n" + + " boolean b13 = s1 == l1;\n" + + " boolean b14 = s1 == l2;\n" + + " boolean b15 = s1 != l1;\n" + + " boolean b16 = s1 != l2;\n" + + " }\n" + + " Zork z;\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " boolean b1 = 1 == 1;\n" + + " ^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " boolean b2 = 1 != 1;\n" + + " ^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "3. WARNING in X.java (at line 5)\n" + + " boolean b3 = 1 == 1.0;\n" + + " ^^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "4. WARNING in X.java (at line 6)\n" + + " boolean b4 = 1 != 1.0;\n" + + " ^^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "5. WARNING in X.java (at line 13)\n" + + " boolean b9 = 1 == s1;\n" + + " ^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "6. WARNING in X.java (at line 15)\n" + + " boolean b91 = 1 != s1;\n" + + " ^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "7. WARNING in X.java (at line 19)\n" + + " boolean b11 = 1 == l1;\n" + + " ^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "8. WARNING in X.java (at line 21)\n" + + " boolean b111 = 1 != l1;\n" + + " ^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "9. WARNING in X.java (at line 23)\n" + + " boolean b13 = s1 == l1;\n" + + " ^^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "10. WARNING in X.java (at line 25)\n" + + " boolean b15 = s1 != l1;\n" + + " ^^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "11. ERROR in X.java (at line 28)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n"); +} + +/** + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=276741" + */ +public void test0039() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " public void gain(String[] args) {\n" + + " boolean b1 = this == this;\n" + + " boolean b2 = this != this;\n" + + " boolean b3 = this != new X();\n" + + " boolean b4 = this == new X();\n" + + " }\n" + + " Zork z;\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " boolean b1 = this == this;\n" + + " ^^^^^^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "2. WARNING in X.java (at line 4)\n" + + " boolean b2 = this != this;\n" + + " ^^^^^^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "3. ERROR in X.java (at line 8)\n" + + " Zork z;\n" + + " ^^^^\n" + + "Zork cannot be resolved to a type\n" + + "----------\n"); +} } \ No newline at end of file Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v retrieving revision 1.79 diff -u -r1.79 NullReferenceTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 24 Nov 2008 13:14:04 -0000 1.79 +++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 25 May 2009 11:47:40 -0000 @@ -705,10 +705,15 @@ "----------\n" + "1. WARNING in X.java (at line 3)\n" + " Object o = (1 == 1) ? null : new Object();\n" + + " ^^^^^^^^\n" + + "Comparing identical expressions\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " Object o = (1 == 1) ? null : new Object();\n" + " ^^^^^^^^^^^^\n" + "Dead code\n" + "----------\n" + - "2. ERROR in X.java (at line 4)\n" + + "3. ERROR in X.java (at line 4)\n" + " o.toString();\n" + " ^\n" + "Null pointer access: The variable o can only be null at this location\n" + #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java,v retrieving revision 1.120 diff -u -r1.120 Expression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 11 Sep 2008 10:04:25 -0000 1.120 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 25 May 2009 11:48:09 -0000 @@ -776,6 +776,8 @@ // case where a static field is retrieved using ClassName.fieldname return qualifiedNameReference.binding; } + } else if (someExpression.isThis()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=276741 + return someExpression.resolvedType; } // } else if (someExpression instanceof PostfixExpression) { // recurse for postfix: i++ --> i // // note: "b = b++" is equivalent to doing nothing, not to "b++" Index: compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java,v retrieving revision 1.73 diff -u -r1.73 EqualExpression.java --- compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 7 Mar 2009 01:08:07 -0000 1.73 +++ compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 25 May 2009 11:48:08 -0000 @@ -813,6 +813,12 @@ Binding leftDirect = Expression.getDirectBinding(this.left); if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) { scope.problemReporter().comparingIdenticalExpressions(this); + } else if (this.constant != Constant.NotAConstant) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=276740 + int operator = (this.bits & OperatorMASK) >> OperatorSHIFT; + if ((operator == EQUAL_EQUAL && this.constant == BooleanConstant.fromValue(true)) + || (operator == NOT_EQUAL && this.constant == BooleanConstant.fromValue(false))) + scope.problemReporter().comparingIdenticalExpressions(this); } return this.resolvedType = TypeBinding.BOOLEAN; }