From: Jürg Billeter Date: Sun, 16 Aug 2009 15:06:50 +0000 (+0200) Subject: Respect accessibility of creation methods X-Git-Tag: 0.7.6~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec5a591a714d9ad0ecb04f969a703ffb0b2e5bec;p=thirdparty%2Fvala.git Respect accessibility of creation methods Fixes bug 560974. --- diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala index 763c5a438..860ccf7e9 100644 --- a/vala/valaobjectcreationexpression.vala +++ b/vala/valaobjectcreationexpression.vala @@ -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;