Casting struct T? to struct T while setting a property doesn't work
The following code fails to compile:
struct SomeStruct {
string some_value;
}
SomeStruct? func() {
return SomeStruct () { some_value = "" };
}
public class OtherClass : GLib.Object {
private SomeStruct info { get; set; }
public OtherClass() {
this.info = (!) func ();
}
[GtkCallback]
private void on_activity_type_row_activated (Gtk.ListBoxRow r) {
var activity = func ();
if (activity != null) {
this.info = (!) activity;
}
}
}
int main() {
var activity = func ();
var not_null = (!) activity;
return 0;
}
/var/home/rasmus/Downloads/reproducer.vala.c: In function 'otherclass_on_activity_type_row_activated':
/var/home/rasmus/Downloads/reproducer.vala.c:202:30: error: lvalue required as unary '&' operand
202 | otherclass_set_info (self, &((SomeStruct) (*_tmp2_)));
| ^
error: cc exited with status 256
If OtherClass.info
isn't a property or when using a temporary variable it works:
public class OtherClass : GLib.Object {
private SomeStruct info { get; set; }
public OtherClass() {
var temp = (!) func ();
this.info = temp;
}
[GtkCallback]
private void on_activity_type_row_activated (Gtk.ListBoxRow r) {
var activity = func ();
if (activity != null) {
var temp = (!) activity;
this.info = temp;
}
}
}