From: Jürg Billeter Date: Mon, 17 Aug 2009 16:48:47 +0000 (+0200) Subject: Do not chain up constructors when using construct properties X-Git-Tag: 0.7.6~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecb290e6501ed6adcbee84b659c85ad38fac5da6;p=thirdparty%2Fvala.git Do not chain up constructors when using construct properties --- diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 0ba3bc9fd..1ce0814ea 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -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; diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala index 1279b9601..6a57805d2 100644 --- a/vala/valacreationmethod.vala +++ b/vala/valacreationmethod.vala @@ -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) {