]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Do not allow assigning to construct-only properties of foreign objects
authorJürg Billeter <j@bitron.ch>
Sat, 19 Dec 2009 11:46:15 +0000 (12:46 +0100)
committerJürg Billeter <j@bitron.ch>
Sat, 19 Dec 2009 11:46:15 +0000 (12:46 +0100)
Fixes bug 604590.

vala/valaassignment.vala

index 2ae05665c69db0dbfc911e8d335513fc1101dbf8..004cc7f4f04d15a4daf259c4fe6097afece14a65 100644 (file)
@@ -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;