diff options
author | Jürg Billeter <j@bitron.ch> | 2010-03-22 19:47:57 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2010-03-22 19:47:57 +0100 |
commit | baf836c29d0732ce620eabd2f01fe384e5f3a533 (patch) | |
tree | 91974e301116a626ecc8d52463d1915eecf4eb2f | |
parent | c006b3b4f5076d52cfc902e5463cfc74d1dd6019 (diff) | |
download | vala-baf836c29d0732ce620eabd2f01fe384e5f3a533.tar.gz |
Fix instance access check for static lambda expressions
Fixes bug 612139.
-rw-r--r-- | vala/valamemberaccess.vala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala index 2914eba83..c566995ac 100644 --- a/vala/valamemberaccess.vala +++ b/vala/valamemberaccess.vala @@ -218,34 +218,43 @@ public class Vala.MemberAccess : Expression { base_symbol = analyzer.current_symbol; + // track whether method has been found to make sure that access + // to instance member is denied from within static lambda expressions + bool method_found = false; + var sym = analyzer.current_symbol; while (sym != null && symbol_reference == null) { - if (this_parameter == null) { + if (!method_found) { if (sym is CreationMethod) { var cm = (CreationMethod) sym; this_parameter = cm.this_parameter; may_access_instance_members = true; may_access_klass_members = true; + method_found = true; } else if (sym is Property) { var prop = (Property) sym; this_parameter = prop.this_parameter; may_access_instance_members = (prop.binding == MemberBinding.INSTANCE); may_access_klass_members = (prop.binding != MemberBinding.STATIC); + method_found = true; } else if (sym is Constructor) { var c = (Constructor) sym; this_parameter = c.this_parameter; may_access_instance_members = (c.binding == MemberBinding.INSTANCE); may_access_klass_members = true; + method_found = true; } else if (sym is Destructor) { var d = (Destructor) sym; this_parameter = d.this_parameter; may_access_instance_members = (d.binding == MemberBinding.INSTANCE); may_access_klass_members = true; + method_found = true; } else if (sym is Method) { var m = (Method) sym; this_parameter = m.this_parameter; may_access_instance_members = (m.binding == MemberBinding.INSTANCE); may_access_klass_members = (m.binding != MemberBinding.STATIC); + method_found = true; } } |