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 |