2008-02-15 Jürg Billeter <j@bitron.ch>
+ * gobject/valaccodeassignmentbinding.vala,
+ gobject/valaccodegenerator.vala: generate casts for property
+ assignments where necessary, fixes bug 511732
+
+2008-02-15 Jürg Billeter <j@bitron.ch>
+
* vala/valamethod.vala, vala/valasemanticanalyzer.vala,
gobject/valaccodegenerator.vala: fix memory management of
parameters with ownership transfer, fixes bug 511642
} else {
CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode;
+ // ensure to pass the value correctly typed (especially important for varargs)
+ cexpr = codegen.get_implicit_cast_expression (cexpr, assignment.right.static_type, prop.type_reference);
+
if (!prop.no_accessor_method) {
if (prop.type_reference.is_real_struct_type ()) {
- cexpr = codegen.get_address_of_expression (assignment.right, codegen.get_implicit_cast_expression (cexpr, assignment.right.static_type, prop.type_reference));
- } else {
- cexpr = codegen.get_implicit_cast_expression (cexpr, assignment.right.static_type, prop.type_reference);
+ cexpr = codegen.get_address_of_expression (assignment.right, cexpr);
}
}
if (context.checking && target_type.data_type != null && target_type.data_type.is_subtype_of (gtypeinstance_type)) {
return new InstanceCast (cexpr, target_type.data_type);
- } else if (target_type.data_type != null && target_type.data_type.is_reference_type () && expression_type.get_cname () != target_type.get_cname ()) {
- return new CCodeCastExpression (cexpr, target_type.get_cname ());
+ } else if (target_type.data_type != null && expression_type.get_cname () != target_type.get_cname ()) {
+ var st = target_type.data_type as Struct;
+ if (target_type.data_type.is_reference_type () || (st != null && st.is_simple_type ())) {
+ // don't cast non-simple structs
+ return new CCodeCastExpression (cexpr, target_type.get_cname ());
+ } else {
+ return cexpr;
+ }
} else if (target_type is DelegateType && expression_type is MethodType) {
var dt = (DelegateType) target_type;
var mt = (MethodType) expression_type;