]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Deprecate assigning to construct-only properties
authorJürg Billeter <j@bitron.ch>
Wed, 21 Oct 2009 21:53:58 +0000 (23:53 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 21 Oct 2009 21:55:48 +0000 (23:55 +0200)
Object (property: value) constructor chain up is recommended to set
construct-only properties.

vala/valaassignment.vala
vala/valamarkupreader.vala
vapigen/valavapicheck.vala

index 06ad297a31c7acccbeac49afca8e5ee27082cbfc..2ae05665c69db0dbfc911e8d335513fc1101dbf8 100644 (file)
@@ -273,6 +273,10 @@ public class Vala.Assignment : Expression {
                                        ma.error = true;
                                        Report.error (ma.source_reference, "Property `%s' is read-only".printf (prop.get_full_name ()));
                                        return false;
+                               } 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");
                                }
                        } else if (ma.symbol_reference is LocalVariable && right.value_type == null) {
                                var local = (LocalVariable) ma.symbol_reference;
index 96ad0e809c46b00458c604c79b76c88f65cc2261..41ec731ffd7a9eaf9499ac6e2486379edfeb96fc 100644 (file)
@@ -26,7 +26,7 @@ using GLib;
  * Simple reader for a subset of XML.
  */
 public class Vala.MarkupReader : Object {
-       public string filename { get; construct; }
+       public string filename { get; private set; }
 
        public string name { get; private set; }
 
index 9494f0521b73874f97bf61fb4ef8ea141b0b09b2..a59b010e2650ca77fdf8c24ae1ad0e45196d3a0f 100644 (file)
@@ -29,9 +29,9 @@ class Vala.VAPICheck : Object {
                this.context = context;
        }
 
-       public CodeContext context { get; construct; }
-       public SourceFile gidl { get; construct; }
-       public SourceFile metadata { get; construct; }
+       public CodeContext context { get; private set; }
+       public SourceFile gidl { get; private set; }
+       public SourceFile metadata { get; private set; }
 
        private List<string> _scope;
        private Set<string> _symbols;