From: Jürg Billeter Date: Sat, 19 Dec 2009 11:46:15 +0000 (+0100) Subject: Do not allow assigning to construct-only properties of foreign objects X-Git-Tag: 0.7.9~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a3de5acd943b6b971b546293be062962517e70f3;p=thirdparty%2Fvala.git Do not allow assigning to construct-only properties of foreign objects Fixes bug 604590. --- diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala index 2ae05665c..004cc7f4f 100644 --- a/vala/valaassignment.vala +++ b/vala/valaassignment.vala @@ -276,7 +276,13 @@ public class Vala.Assignment : Expression { } else if (!analyzer.context.deprecated && !prop.set_accessor.writable && analyzer.find_current_method () is CreationMethod) { - Report.warning (ma.source_reference, "assigning to construct-only properties is deprecated, use Object (property: value) constructor chain up"); + if (ma.inner.symbol_reference != analyzer.find_current_method ().this_parameter) { + // trying to set construct-only property in creation method for foreign instance + Report.error (ma.source_reference, "Property `%s' is read-only".printf (prop.get_full_name ())); + return false; + } else { + Report.warning (ma.source_reference, "assigning to construct-only properties is deprecated, use Object (property: value) constructor chain up"); + } } } else if (ma.symbol_reference is LocalVariable && right.value_type == null) { var local = (LocalVariable) ma.symbol_reference;