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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterRecoveryTest.java (-2 / +6 lines)
Lines 978-988 Link Here
978
				"===== Details =====\n" + 
978
				"===== Details =====\n" + 
979
				"1:EMPTY_STATEMENT,[77,0],,RECOVERED,[N/A]\n" + 
979
				"1:EMPTY_STATEMENT,[77,0],,RECOVERED,[N/A]\n" + 
980
				"===== Problems =====\n" + 
980
				"===== Problems =====\n" + 
981
				"1. ERROR in /Converter/src/p/X.java (at line 4)\n" + 
981
				"1. WARNING in /Converter/src/p/X.java (at line 4)\n" + 
982
				"	if (1==1 && var.equals(1) {\n" + 
983
				"	    ^^^^\n" + 
984
				"Comparing identical expressions\n" + 
985
				"2. ERROR in /Converter/src/p/X.java (at line 4)\n" + 
982
				"	if (1==1 && var.equals(1) {\n" + 
986
				"	if (1==1 && var.equals(1) {\n" + 
983
				"	                ^^^^^^\n" + 
987
				"	                ^^^^^^\n" + 
984
				"The method equals(Object) in the type Object is not applicable for the arguments (int)\n" + 
988
				"The method equals(Object) in the type Object is not applicable for the arguments (int)\n" + 
985
				"2. ERROR in /Converter/src/p/X.java (at line 4)\n" + 
989
				"3. ERROR in /Converter/src/p/X.java (at line 4)\n" + 
986
				"	if (1==1 && var.equals(1) {\n" + 
990
				"	if (1==1 && var.equals(1) {\n" + 
987
				"	                        ^\n" + 
991
				"	                        ^\n" + 
988
				"Syntax error, insert \") Statement\" to complete BlockStatements\n",
992
				"Syntax error, insert \") Statement\" to complete BlockStatements\n",
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java (+130 lines)
Lines 1399-1402 Link Here
1399
			"Zork cannot be resolved to a type\n" +
1399
			"Zork cannot be resolved to a type\n" +
1400
			"----------\n");
1400
			"----------\n");
1401
}
1401
}
1402
1403
/**
1404
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=276740"
1405
 */
1406
public void test0038() {
1407
	this.runNegativeTest(
1408
		new String[] {
1409
			"X.java",
1410
			"public class X {\n" +
1411
			"	public static void main(String[] args) {\n" +
1412
			"		boolean b1 = 1 == 1;\n" +
1413
			"		boolean b2 = 1 != 1;\n" +
1414
			"		boolean b3 = 1 == 1.0;\n" +
1415
			"		boolean b4 = 1 != 1.0;\n" +
1416
			"		boolean b5 = 1 == 2;\n" +
1417
			"		boolean b6 = 1 != 2;\n" +
1418
			"		boolean b7 = 1 == 2.0;\n" +
1419
			"		boolean b8 = 1 != 2.0;\n" +
1420
			"       final short s1 = 1;\n" +
1421
			"       final short s2 = 2;\n" +
1422
			"       boolean b9 = 1 == s1;\n" +
1423
			"       boolean b10 = 1 == s2;\n" +
1424
			"       boolean b91 = 1 != s1;\n" +
1425
			"       boolean b101 = 1 != s2;\n" +
1426
			"       final long l1 = 1;\n" +
1427
			"       final long l2 = 2;\n" +
1428
			"       boolean b11 = 1 == l1;\n" +
1429
			"       boolean b12 = 1 == l2;\n" +
1430
			"       boolean b111 = 1 != l1;\n" +
1431
			"       boolean b121 = 1 != l2;\n" +
1432
			"       boolean b13 = s1 == l1;\n" +
1433
			"       boolean b14 = s1 == l2;\n" +
1434
			"       boolean b15 = s1 != l1;\n" +
1435
			"       boolean b16 = s1 != l2;\n" +
1436
			"	}\n" +
1437
			"	Zork z;\n" +
1438
			"}\n"
1439
			},
1440
			"----------\n" + 
1441
			"1. WARNING in X.java (at line 3)\n" + 
1442
			"	boolean b1 = 1 == 1;\n" + 
1443
			"	             ^^^^^^\n" + 
1444
			"Comparing identical expressions\n" + 
1445
			"----------\n" + 
1446
			"2. WARNING in X.java (at line 4)\n" + 
1447
			"	boolean b2 = 1 != 1;\n" + 
1448
			"	             ^^^^^^\n" + 
1449
			"Comparing identical expressions\n" + 
1450
			"----------\n" + 
1451
			"3. WARNING in X.java (at line 5)\n" + 
1452
			"	boolean b3 = 1 == 1.0;\n" + 
1453
			"	             ^^^^^^^^\n" + 
1454
			"Comparing identical expressions\n" + 
1455
			"----------\n" + 
1456
			"4. WARNING in X.java (at line 6)\n" + 
1457
			"	boolean b4 = 1 != 1.0;\n" + 
1458
			"	             ^^^^^^^^\n" + 
1459
			"Comparing identical expressions\n" + 
1460
			"----------\n" + 
1461
			"5. WARNING in X.java (at line 13)\n" + 
1462
			"	boolean b9 = 1 == s1;\n" + 
1463
			"	             ^^^^^^^\n" + 
1464
			"Comparing identical expressions\n" + 
1465
			"----------\n" + 
1466
			"6. WARNING in X.java (at line 15)\n" + 
1467
			"	boolean b91 = 1 != s1;\n" + 
1468
			"	              ^^^^^^^\n" + 
1469
			"Comparing identical expressions\n" + 
1470
			"----------\n" + 
1471
			"7. WARNING in X.java (at line 19)\n" + 
1472
			"	boolean b11 = 1 == l1;\n" + 
1473
			"	              ^^^^^^^\n" + 
1474
			"Comparing identical expressions\n" + 
1475
			"----------\n" + 
1476
			"8. WARNING in X.java (at line 21)\n" + 
1477
			"	boolean b111 = 1 != l1;\n" + 
1478
			"	               ^^^^^^^\n" + 
1479
			"Comparing identical expressions\n" + 
1480
			"----------\n" + 
1481
			"9. WARNING in X.java (at line 23)\n" + 
1482
			"	boolean b13 = s1 == l1;\n" + 
1483
			"	              ^^^^^^^^\n" + 
1484
			"Comparing identical expressions\n" + 
1485
			"----------\n" + 
1486
			"10. WARNING in X.java (at line 25)\n" + 
1487
			"	boolean b15 = s1 != l1;\n" + 
1488
			"	              ^^^^^^^^\n" + 
1489
			"Comparing identical expressions\n" + 
1490
			"----------\n" + 
1491
			"11. ERROR in X.java (at line 28)\n" + 
1492
			"	Zork z;\n" + 
1493
			"	^^^^\n" + 
1494
			"Zork cannot be resolved to a type\n" + 
1495
			"----------\n");
1496
}
1497
1498
/**
1499
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=276741"
1500
 */
1501
public void test0039() {
1502
	this.runNegativeTest(
1503
		new String[] {
1504
			"X.java",
1505
			"public class X {\n" +
1506
			"	public void gain(String[] args) {\n" +
1507
			"		boolean b1 = this == this;\n" +
1508
			"		boolean b2 = this != this;\n" +		
1509
			"		boolean b3 = this != new X();\n" +
1510
			"		boolean b4 = this == new X();\n" +
1511
			"	}\n" +
1512
			"	Zork z;\n" +
1513
			"}\n"
1514
			},
1515
			"----------\n" + 
1516
			"1. WARNING in X.java (at line 3)\n" + 
1517
			"	boolean b1 = this == this;\n" + 
1518
			"	             ^^^^^^^^^^^^\n" + 
1519
			"Comparing identical expressions\n" + 
1520
			"----------\n" + 
1521
			"2. WARNING in X.java (at line 4)\n" + 
1522
			"	boolean b2 = this != this;\n" + 
1523
			"	             ^^^^^^^^^^^^\n" + 
1524
			"Comparing identical expressions\n" + 
1525
			"----------\n" + 
1526
			"3. ERROR in X.java (at line 8)\n" + 
1527
			"	Zork z;\n" + 
1528
			"	^^^^\n" + 
1529
			"Zork cannot be resolved to a type\n" + 
1530
			"----------\n");
1531
}
1402
}
1532
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (-1 / +6 lines)
Lines 705-714 Link Here
705
			"----------\n" + 
705
			"----------\n" + 
706
			"1. WARNING in X.java (at line 3)\n" + 
706
			"1. WARNING in X.java (at line 3)\n" + 
707
			"	Object o = (1 == 1) ? null : new Object();\n" + 
707
			"	Object o = (1 == 1) ? null : new Object();\n" + 
708
			"	           ^^^^^^^^\n" + 
709
			"Comparing identical expressions\n" + 
710
			"----------\n" + 
711
			"2. WARNING in X.java (at line 3)\n" + 
712
			"	Object o = (1 == 1) ? null : new Object();\n" + 
708
			"	                             ^^^^^^^^^^^^\n" + 
713
			"	                             ^^^^^^^^^^^^\n" + 
709
			"Dead code\n" + 
714
			"Dead code\n" + 
710
			"----------\n" + 
715
			"----------\n" + 
711
			"2. ERROR in X.java (at line 4)\n" + 
716
			"3. ERROR in X.java (at line 4)\n" + 
712
			"	o.toString();\n" + 
717
			"	o.toString();\n" + 
713
			"	^\n" + 
718
			"	^\n" + 
714
			"Null pointer access: The variable o can only be null at this location\n" + 
719
			"Null pointer access: The variable o can only be null at this location\n" + 
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java (+2 lines)
Lines 776-781 Link Here
776
			// case where a static field is retrieved using ClassName.fieldname
776
			// case where a static field is retrieved using ClassName.fieldname
777
			return qualifiedNameReference.binding;
777
			return qualifiedNameReference.binding;
778
		}
778
		}
779
	} else if (someExpression.isThis()) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=276741
780
		return someExpression.resolvedType;
779
	}
781
	}
780
//		} else if (someExpression instanceof PostfixExpression) { // recurse for postfix: i++ --> i
782
//		} else if (someExpression instanceof PostfixExpression) { // recurse for postfix: i++ --> i
781
//			// note: "b = b++" is equivalent to doing nothing, not to "b++"
783
//			// note: "b = b++" is equivalent to doing nothing, not to "b++"
(-)compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java (+6 lines)
Lines 813-818 Link Here
813
			Binding leftDirect = Expression.getDirectBinding(this.left);
813
			Binding leftDirect = Expression.getDirectBinding(this.left);
814
			if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) {
814
			if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) {
815
				scope.problemReporter().comparingIdenticalExpressions(this);
815
				scope.problemReporter().comparingIdenticalExpressions(this);
816
			} else if (this.constant != Constant.NotAConstant) {
817
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=276740
818
				int operator = (this.bits & OperatorMASK) >> OperatorSHIFT;
819
				if ((operator == EQUAL_EQUAL && this.constant == BooleanConstant.fromValue(true))
820
						|| (operator == NOT_EQUAL && this.constant == BooleanConstant.fromValue(false)))
821
					scope.problemReporter().comparingIdenticalExpressions(this);
816
			}
822
			}
817
			return this.resolvedType = TypeBinding.BOOLEAN;
823
			return this.resolvedType = TypeBinding.BOOLEAN;
818
		}
824
		}

Return to bug 276740