]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Respect accessibility of creation methods
authorJürg Billeter <j@bitron.ch>
Sun, 16 Aug 2009 15:06:50 +0000 (17:06 +0200)
committerJürg Billeter <j@bitron.ch>
Sun, 16 Aug 2009 15:18:29 +0000 (17:18 +0200)
Fixes bug 560974.

vala/valaobjectcreationexpression.vala

index 763c5a4389b9ff191e0d6a02bfd9506ff11fa469..860ccf7e9c7583cb241dbda2d2fb0bf04be58ee5 100644 (file)
@@ -256,6 +256,22 @@ public class Vala.ObjectCreationExpression : Expression {
                                }
                        }
 
+                       if (symbol_reference != null && symbol_reference.access == SymbolAccessibility.PRIVATE) {
+                               bool in_target_type = false;
+                               for (Symbol this_symbol = analyzer.current_symbol; this_symbol != null; this_symbol = this_symbol.parent_symbol) {
+                                       if (this_symbol == cl) {
+                                               in_target_type = true;
+                                               break;
+                                       }
+                               }
+
+                               if (!in_target_type) {
+                                       error = true;
+                                       Report.error (source_reference, "Access to private member `%s' denied".printf (symbol_reference.get_full_name ()));
+                                       return false;
+                               }
+                       }
+
                        while (cl != null) {
                                if (cl.get_ref_sink_function () != null) {
                                        value_type.floating_reference = true;