]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix nullable struct properties
authorJürg Billeter <j@bitron.ch>
Fri, 8 Jan 2010 20:22:09 +0000 (21:22 +0100)
committerJürg Billeter <j@bitron.ch>
Fri, 8 Jan 2010 20:22:09 +0000 (21:22 +0100)
Fixes bug 606202.

codegen/valaccodeassignmentmodule.vala
codegen/valaccodememberaccessmodule.vala
tests/Makefile.am
tests/structs/bug606202.vala [new file with mode: 0644]

index 451d411071d39d3fca032beb715870be0a78fc35..80be69cf83c151a04c9af83d2db81a1b21596f8b 100644 (file)
@@ -55,7 +55,7 @@ internal class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
                        CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode;
 
                        if (!prop.no_accessor_method) {
-                               if (prop.property_type.is_real_struct_type ()) {
+                               if (prop.property_type.is_real_non_null_struct_type ()) {
                                        cexpr = get_address_of_expression (assignment.right, cexpr);
                                }
                        }
index 9e242d08ee162ae0480f9af3026e5cc02c4e9afe..b4984402af67c17a9ee8dc0c7813e009de406a1d 100644 (file)
@@ -275,7 +275,7 @@ internal class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 
                                // Property access to real struct types is handled differently
                                // The value is returned by out parameter
-                               if (base_property.property_type.is_real_struct_type ()) {
+                               if (base_property.property_type.is_real_non_null_struct_type ()) {
                                        var ccomma = new CCodeCommaExpression ();
                                        var temp_var = get_temp_variable (base_property.get_accessor.value_type);
                                        var ctemp = get_variable_cexpression (temp_var.name);
index 9698cfa37d4a75216616d15f7404da6b33e62500..e9628cd96517b16cd1c1cc04da5768dd84723378 100644 (file)
@@ -43,6 +43,7 @@ TESTS = \
        structs/bug530605.vala \
        structs/bug583603.vala \
        structs/bug595587.vala \
+       structs/bug606202.vala \
        delegates/delegates.vala \
        delegates/bug595610.vala \
        delegates/bug595639.vala \
diff --git a/tests/structs/bug606202.vala b/tests/structs/bug606202.vala
new file mode 100644 (file)
index 0000000..78beb5b
--- /dev/null
@@ -0,0 +1,18 @@
+struct Foo {
+       string s;
+
+       public Foo (string s) {
+               this.s = s;
+       }
+}
+
+class Bar : Object {
+       public Foo? foo { get; set; }
+}
+
+void main () {
+       var bar = new Bar ();
+       var foo = Foo ("hello");
+       bar.foo = foo;
+       assert (bar.foo.s == "hello");
+}