[vala] Do not warn on assignment to same variable of different instance
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Do not warn on assignment to same variable of different instance
- Date: Sat, 20 Mar 2010 15:51:08 +0000 (UTC)
commit 7f87e7cc375c18365066133a416486e322734b52
Author: Jürg Billeter <j bitron ch>
Date: Sat Mar 20 16:50:18 2010 +0100
Do not warn on assignment to same variable of different instance
vala/valaassignment.vala | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 38fda74..212685c 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -358,9 +358,22 @@ public class Vala.Assignment : Expression {
}
var right_ma = right as MemberAccess;
- if (right_ma != null && ma.symbol_reference == right_ma.symbol_reference &&
- (ma.symbol_reference is LocalVariable || ma.symbol_reference is Field || ma.symbol_reference is FormalParameter)) {
- Report.warning (source_reference, "Assignment to same variable");
+ if (right_ma != null && ma.symbol_reference == right_ma.symbol_reference) {
+ if (ma.symbol_reference is LocalVariable || ma.symbol_reference is FormalParameter) {
+ Report.warning (source_reference, "Assignment to same variable");
+ } else if (ma.symbol_reference is Field) {
+ var f = (Field) ma.symbol_reference;
+ if (f.binding == MemberBinding.STATIC) {
+ Report.warning (source_reference, "Assignment to same variable");
+ } else {
+ var ma_inner = ma.inner as MemberAccess;
+ var right_ma_inner = right_ma.inner as MemberAccess;
+ if (ma_inner != null && ma_inner.member_name == "this" && ma_inner.inner == null &&
+ right_ma_inner != null && right_ma_inner.member_name == "this" && right_ma_inner.inner == null) {
+ Report.warning (source_reference, "Assignment to same variable");
+ }
+ }
+ }
}
} else if (left is ElementAccess) {
var ea = (ElementAccess) left;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]