]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix protected member access check in inner classes
authorJürg Billeter <j@bitron.ch>
Mon, 1 Feb 2010 16:39:51 +0000 (17:39 +0100)
committerJürg Billeter <j@bitron.ch>
Mon, 1 Feb 2010 16:40:18 +0000 (17:40 +0100)
vala/valamemberaccess.vala

index a3ea746f0ca426d24a5764d705dda00ff21dddb3..6f7f51034f95491d106c64d9cf69cbab0b2efa49 100644 (file)
@@ -550,9 +550,18 @@ public class Vala.MemberAccess : Expression {
                member.used = true;
 
                if (access == SymbolAccessibility.PROTECTED) {
-                       var subtype = (analyzer.current_class != null && analyzer.current_class.is_subtype_of ((TypeSymbol) member.parent_symbol));
+                       var target_type = (TypeSymbol) member.parent_symbol;
 
-                       if (!subtype) {
+                       bool in_subtype = false;
+                       for (Symbol this_symbol = analyzer.current_symbol; this_symbol != null; this_symbol = this_symbol.parent_symbol) {
+                               var cl = this_symbol as Class;
+                               if (cl != null && cl.is_subtype_of (target_type)) {
+                                       in_subtype = true;
+                                       break;
+                               }
+                       }
+
+                       if (!in_subtype) {
                                error = true;
                                Report.error (source_reference, "Access to protected member `%s' denied".printf (member.get_full_name ()));
                                return false;