]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Report error when using instance method as argument in static methods
authorJürg Billeter <j@bitron.ch>
Mon, 22 Mar 2010 22:12:47 +0000 (23:12 +0100)
committerJürg Billeter <j@bitron.ch>
Mon, 22 Mar 2010 22:12:47 +0000 (23:12 +0100)
Fixes bug 598839.

vala/valasemanticanalyzer.vala

index 130e2ca4d848d24a50cdd64f7d0ebf75f50b754d..818ea7d5047878e56fde51362c937946d6875725 100644 (file)
@@ -566,6 +566,15 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                                }
                        }
                }
+               var ma = arg as MemberAccess;
+               if (ma != null && ma.prototype_access) {
+                       // allow prototype access if target type is delegate without target
+                       var deleg_type = arg.target_type as DelegateType;
+                       if (deleg_type == null || deleg_type.delegate_symbol.has_target) {
+                               Report.error (arg.source_reference, "Access to instance member `%s' denied".printf (arg.symbol_reference.get_full_name ()));
+                       }
+                       return false;
+               }
                return true;
        }