Commit ddea34ce authored by Luca Bruno's avatar Luca Bruno Committed by Jürg Billeter

Support implicit GValue conversion when assigning to properties

Thanks to Michal Hruby for the test case.

Fixes bug 620706.
parent 0a14bd53
......@@ -5484,6 +5484,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
* from a vala to C point of view all expressions denoting locals, fields and
* parameters are eligable to an ADDRESS_OF operator */
public bool is_address_of_possible (Expression e) {
if (gvalue_type != null && e.target_type.data_type == gvalue_type && e.value_type.data_type != gvalue_type) {
// implicit conversion to GValue is not addressable
return false;
}
var ma = e as MemberAccess;
if (ma == null) {
......@@ -5502,7 +5507,14 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
var ccomma = new CCodeCommaExpression ();
var temp_decl = get_temp_variable (e.value_type, true, null, false);
DataType address_of_type;
if (gvalue_type != null && e.target_type != null && e.target_type.data_type == gvalue_type) {
// implicit conversion to GValue
address_of_type = e.target_type;
} else {
address_of_type = e.value_type;
}
var temp_decl = get_temp_variable (address_of_type, true, null, false);
var ctemp = get_variable_cexpression (temp_decl.name);
temp_vars.add (temp_decl);
ccomma.append_expression (new CCodeAssignment (ctemp, ce));
......
......@@ -69,6 +69,7 @@ TESTS = \
objects/bug597155.vala \
objects/bug597161.vala \
objects/bug613486.vala \
objects/bug620706.vala \
errors/errors.vala \
errors/bug567181.vala \
errors/bug579101.vala \
......
class Foo : Object {
public Value val { get; set; }
}
struct Bar {
int dummy;
}
void main () {
var f = new Foo ();
var b = Bar ();
f.val = b;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment