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

(-)org/eclipse/jdt/core/compiler/IProblem.java (+2 lines)
Lines 489-492 Link Here
489
	// detected task
489
	// detected task
490
	/** @since 2.1 */
490
	/** @since 2.1 */
491
	int Task = Internal + 450;
491
	int Task = Internal + 450;
492
	
493
	int NoOpAssignment = 498; 
492
}
494
}
(-)org/eclipse/jdt/internal/compiler/ast/Assignment.java (-1 / +23 lines)
Lines 19-25 Link Here
19
19
20
	public Reference lhs;
20
	public Reference lhs;
21
	public Expression expression;
21
	public Expression expression;
22
	
22
	public TypeBinding lhsType;	
23
	public Assignment(Expression lhs, Expression expression, int sourceEnd) {
23
	public Assignment(Expression lhs, Expression expression, int sourceEnd) {
24
		//lhs is always a reference by construction ,
24
		//lhs is always a reference by construction ,
25
		//but is build as an expression ==> the checkcast cannot fail
25
		//but is build as an expression ==> the checkcast cannot fail
Lines 69-74 Link Here
69
		if (this.resolvedType == null || rhsType == null)
69
		if (this.resolvedType == null || rhsType == null)
70
			return null;
70
			return null;
71
71
72
		checkNoOp(scope);
73
72
		// Compile-time conversion of base-types : implicit narrowing integer into byte/short/character
74
		// Compile-time conversion of base-types : implicit narrowing integer into byte/short/character
73
		// may require to widen the rhs expression at runtime
75
		// may require to widen the rhs expression at runtime
74
		if ((expression.isConstantValueOfTypeAssignableToType(rhsType, this.resolvedType)
76
		if ((expression.isConstantValueOfTypeAssignableToType(rhsType, this.resolvedType)
Lines 84-89 Link Here
84
		return null;
86
		return null;
85
	}
87
	}
86
88
89
	Binding getBinding(Expression ref) {
90
		if (ref instanceof FieldReference) {
91
			return ((Reference)ref).fieldBinding();
92
		} else if (ref instanceof NameReference) {
93
			return ((NameReference)ref).binding;
94
		}
95
		return null;
96
	}
97
98
	private void checkNoOp(BlockScope scope) {
99
		
100
		Binding lhsBinding = getBinding(lhs);
101
		Binding rhsBinding = getBinding(expression);
102
		if (lhsBinding == rhsBinding) {
103
			scope.problemReporter().noOpAssignment(this);
104
		}
105
	}
106
	
107
		
108
	
87
	public String toString(int tab) {
109
	public String toString(int tab) {
88
110
89
		//no () when used as a statement 
111
		//no () when used as a statement 
(-)org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-1 / +14 lines)
Lines 549-555 Link Here
549
			if ((warningThreshold & CompilerOptions.StaticAccessReceiver) != 0){
549
			if ((warningThreshold & CompilerOptions.StaticAccessReceiver) != 0){
550
				return Warning;
550
				return Warning;
551
			}
551
			}
552
			return Ignore;		
552
			return Ignore;
553
		case IProblem.NoOpAssignment:
554
			return Warning;
555
				
553
		case IProblem.Task :
556
		case IProblem.Task :
554
			return Warning;			
557
			return Warning;			
555
		default:
558
		default:
Lines 2631-2636 Link Here
2631
		location.sourceStart,
2634
		location.sourceStart,
2632
		location.sourceEnd);
2635
		location.sourceEnd);
2633
}
2636
}
2637
2638
public void noOpAssignment(Assignment assignment) {
2639
	this.handle(
2640
		IProblem.NoOpAssignment,
2641
		new String[] {assignment.lhs.toString(), assignment.expression.toString()},
2642
		new String[] {assignment.toString() },
2643
		assignment.sourceStart,
2644
		assignment.sourceEnd);
2645
}
2646
2634
public void typeMismatchErrorActualTypeExpectedType(Expression expression, TypeBinding constantType, TypeBinding expectedType) {
2647
public void typeMismatchErrorActualTypeExpectedType(Expression expression, TypeBinding constantType, TypeBinding expectedType) {
2635
	String constantTypeName = new String(constantType.readableName());
2648
	String constantTypeName = new String(constantType.readableName());
2636
	String expectedTypeName = new String(expectedType.readableName());
2649
	String expectedTypeName = new String(expectedType.readableName());
(-)org/eclipse/jdt/internal/compiler/problem/messages.properties (-1 / +3 lines)
Lines 268-271 Link Here
268
268
269
440 = ''assert'' should not be used as an identifier, since it is a reserved keyword from source level 1.4 on
269
440 = ''assert'' should not be used as an identifier, since it is a reserved keyword from source level 1.4 on
270
270
271
450 = {0} {1}
271
450 = {0} {1}
272
273
498 = The {0} assignment is a no-op

Return to bug 25092