]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Cast instance parameter for property access in object-initializer
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 4 Jan 2019 18:18:11 +0000 (19:18 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 10 Jan 2019 20:54:25 +0000 (21:54 +0100)
This will silence those incompatible-pointer-types warnings

codegen/valaccodebasemodule.vala

index 327da2726368b1ae77e398008ebd598d48bae356..89ed181a8c7a23943eda875996f70e6f53297360 100644 (file)
@@ -5039,10 +5039,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                                generate_class_struct_declaration (cl, cfile);
                                        }
                                } else if (init.symbol_reference is Property) {
-                                       var inst_ma = new MemberAccess.simple ("new");
-                                       inst_ma.value_type = expr.type_reference;
-                                       set_cvalue (inst_ma, instance);
-                                       store_property ((Property) init.symbol_reference, inst_ma, init.initializer.target_value);
+                                       var p = (Property) init.symbol_reference;
+                                       var instance_target_type = get_data_type_for_symbol ((TypeSymbol) p.parent_symbol);
+                                       var typed_inst = transform_value (new GLibValue (expr.type_reference, instance), instance_target_type, init);
+                                       var inst_ma = new MemberAccess.simple ("fake");
+                                       inst_ma.target_value = typed_inst;
+                                       store_property (p, inst_ma, init.initializer.target_value);
                                        // FIXME Do not ref/copy in the first place
                                        if (requires_destroy (init.initializer.target_value.value_type)) {
                                                ccode.add_expression (destroy_value (init.initializer.target_value));