Add test-case and fix code generator for call to the setter to pass
instance as a value rather than as a pointer to value.
Based on patches by Nathan Summers.
https://bugzilla.gnome.org/show_bug.cgi?id=657346
/* target instance is first argument */
var cinstance = (CCodeExpression) get_ccodenode (instance);
- if (prop.parent_symbol is Struct) {
- // we need to pass struct instance by reference
+ if (prop.parent_symbol is Struct && !((Struct) prop.parent_symbol).is_simple_type ()) {
+ // we need to pass struct instance by reference if it isn't a simple-type
var instance_value = instance.target_value;
if (!get_lvalue (instance_value)) {
instance_value = store_temp_value (instance_value, instance);
structs/bug685177.vala \
structs/bug686190.vala \
structs/bug690380.vala \
+ structs/bug694140.vala \
structs/bug749952.vala \
structs/bug775761.vala \
structs/bug777194.vala \
--- /dev/null
+string[] colors;
+
+[SimpleType]
+[CCode (has_type_id = false)]
+struct Foo : int {
+ public string bar {
+ get {
+ return colors[(int) this];
+ }
+ set {
+ colors[(int) this] = value;
+ }
+ }
+}
+
+void main () {
+ colors = { "black", "red", "green", "blue" };
+
+ Foo foo = 1;
+ assert (foo.bar == "red");
+ foo.bar = "white";
+ assert (foo.bar == "white");
+}