[vala] Do not allow assigning to construct-only properties of foreign objects



commit a3de5acd943b6b971b546293be062962517e70f3
Author: Jürg Billeter <j bitron ch>
Date:   Sat Dec 19 12:46:15 2009 +0100

    Do not allow assigning to construct-only properties of foreign objects
    
    Fixes bug 604590.

 vala/valaassignment.vala |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 2ae0566..004cc7f 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]