[vala] Set the type of initializer lists to be non-nullable



commit 3e76339945e23115b40231e8bbeb5d1998d1be70
Author: Luca Bruno <lucabru src gnome org>
Date:   Sun Aug 7 21:05:33 2011 +0200

    Set the type of initializer lists to be non-nullable

 codegen/valaccodebasemodule.vala |    2 +-
 tests/structs/structs.vala       |    1 +
 vala/valainitializerlist.vala    |    7 ++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 26f88ee..b9208e7 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2256,7 +2256,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 				set_cvalue (list, clist);
 			} else {
 				// used as expression
-				var instance = create_temp_value (list.target_type, true, list);
+				var instance = create_temp_value (list.value_type, true, list);
 
 				var field_it = st.get_fields ().iterator ();
 				foreach (Expression expr in list.get_initializers ()) {
diff --git a/tests/structs/structs.vala b/tests/structs/structs.vala
index 2a5c06c..2e4ed7c 100644
--- a/tests/structs/structs.vala
+++ b/tests/structs/structs.vala
@@ -68,6 +68,7 @@ void main () {
 	stdout.printf ("simple_struct.field = %d\n", simple_struct.field);
 
 	test_in_parameter (simple_struct);
+	test_in_parameter ({1});
 	test_in_nullable_parameter (simple_struct);
 	test_ref_parameter (ref simple_struct);
 	stdout.printf ("after test_ref_parameter: st.field = %d\n", simple_struct.field);
diff --git a/vala/valainitializerlist.vala b/vala/valainitializerlist.vala
index e99a415..b2350ae 100644
--- a/vala/valainitializerlist.vala
+++ b/vala/valainitializerlist.vala
@@ -74,6 +74,8 @@ public class Vala.InitializerList : Expression {
 
 	public override void accept (CodeVisitor visitor) {
 		visitor.visit_initializer_list (this);
+
+		visitor.visit_expression (this);
 	}
 
 	public override bool is_constant () {
@@ -203,7 +205,8 @@ public class Vala.InitializerList : Expression {
 
 		if (!error) {
 			/* everything seems to be correct */
-			value_type = target_type;
+			value_type = target_type.copy ();
+			value_type.nullable = false;
 		}
 
 		return !error;
@@ -215,5 +218,7 @@ public class Vala.InitializerList : Expression {
 		}
 
 		codegen.visit_initializer_list (this);
+
+		codegen.visit_expression (this);
 	}
 }



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