[vala] Do not chain up constructors when using construct properties



commit ecb290e6501ed6adcbee84b659c85ad38fac5da6
Author: Jürg Billeter <j bitron ch>
Date:   Mon Aug 17 18:48:47 2009 +0200

    Do not chain up constructors when using construct properties

 codegen/valaccodemethodmodule.vala |   15 ---------------
 vala/valacreationmethod.vala       |   19 ++++++++++++++++++-
 2 files changed, 18 insertions(+), 16 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 0ba3bc9..1ce0814 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 1279b96..6a57805 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) {



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