[vala] Warn when accessing static members with an instance reference



commit 333806694d68646636b060755924ab0f30e3e898
Author: JÃrg Billeter <j bitron ch>
Date:   Mon Aug 6 14:32:06 2012 +0200

    Warn when accessing static members with an instance reference
    
    Fixes bug 661034.

 vala/valamemberaccess.vala |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index f8d581a..8b480e1 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -1,6 +1,6 @@
 /* valamemberaccess.vala
  *
- * Copyright (C) 2006-2011  JÃrg Billeter
+ * Copyright (C) 2006-2012  JÃrg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -771,6 +771,10 @@ public class Vala.MemberAccess : Expression {
 				check_lvalue_access ();
 			}
 
+			if (!instance && !klass && may_access_instance_members && inner != null) {
+				Report.warning (source_reference, "Access to static member `%s' with an instance reference".printf (symbol_reference.get_full_name ()));
+			}
+
 			if (context.experimental_non_null && instance && inner.value_type.nullable &&
 			    !(inner.value_type is PointerType) && !(inner.value_type is GenericType)) {
 				Report.error (source_reference, "Access to instance member `%s' from nullable reference denied".printf (symbol_reference.get_full_name ()));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]