]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Warn when accessing static members with an instance reference
authorJürg Billeter <j@bitron.ch>
Mon, 6 Aug 2012 12:32:06 +0000 (14:32 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 6 Aug 2012 12:36:22 +0000 (14:36 +0200)
Fixes bug 661034.

vala/valamemberaccess.vala

index f8d581afa81c1219b8988993932b5e61f8a2909e..8b480e1f77dce0d2dd0cd597ae9a617c647c0a6a 100644 (file)
@@ -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 ()));