]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Do not chain up constructors when using construct properties
authorJürg Billeter <j@bitron.ch>
Mon, 17 Aug 2009 16:48:47 +0000 (18:48 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 17 Aug 2009 16:48:47 +0000 (18:48 +0200)
codegen/valaccodemethodmodule.vala
vala/valacreationmethod.vala

index 0ba3bc9fd5127ebd8b7d8900726d275a23b422bd..1ce0814eaa7d94a4ea484e8e0c7e10ba477156ee 100644 (file)
@@ -970,21 +970,6 @@ internal class Vala.CCodeMethodModule : CCodeStructModule {
        public override void visit_creation_method (CreationMethod m) {
                bool visible = !m.is_private_symbol ();
 
-               if (m.body != null && current_type_symbol is Class
-                   && gobject_type != null && current_class.is_subtype_of (gobject_type)) {
-                       int n_params = 0;
-                       foreach (Statement stmt in m.body.get_statements ()) {
-                               var expr_stmt = stmt as ExpressionStatement;
-                               if (expr_stmt != null) {
-                                       Property prop = expr_stmt.assigned_property ();
-                                       if (prop != null && prop.set_accessor.construction) {
-                                               n_params++;
-                                       }
-                               }
-                       }
-                       m.n_construction_params = n_params;
-               }
-
                head.visit_method (m);
 
                DataType creturn_type;
index 1279b9601296dffd1613d6e544a82232b2044e16..6a57805d242456dd96d5e6df491b067a1f6913bb 100644 (file)
@@ -151,8 +151,25 @@ public class Vala.CreationMethod : Method {
                if (body != null) {
                        body.check (analyzer);
 
-                       // ensure we chain up to base constructor
                        var cl = parent_symbol as Class;
+
+                       // count construction property assignments
+                       if (analyzer.context.profile == Profile.GOBJECT && cl != null
+                           && cl.is_subtype_of (analyzer.object_type)) {
+                               int n_params = 0;
+                               foreach (Statement stmt in body.get_statements ()) {
+                                       var expr_stmt = stmt as ExpressionStatement;
+                                       if (expr_stmt != null) {
+                                               Property prop = expr_stmt.assigned_property ();
+                                               if (prop != null && prop.set_accessor.construction) {
+                                                       n_params++;
+                                               }
+                                       }
+                               }
+                               n_construction_params = n_params;
+                       }
+
+                       // ensure we chain up to base constructor
                        if (!chain_up && cl != null && cl.base_class != null) {
                                if (cl.base_class.default_construction_method != null
                                    && !cl.base_class.default_construction_method.has_construct_function) {