initializing a delegate field sets the target always to `this`
In the following code, I initialize the func
field using an external static function, which returns its own target. valac
seems to be receiving it correctly, but then ignores it and does self->func_target = self;
.
// bug.vala
delegate void VoidFunc ();
VoidFunc get_void_func () {
var something = "Hi";
return () => print ("%s\n", something);
}
[Compact]
class MyObject {
public VoidFunc func = get_void_func ();
}
void main () {
var obj = new MyObject ();
obj.func ();
}
// bug.c
// ...
static void
my_object_instance_init (MyObject * self)
{
gpointer _tmp0_ = NULL;
GDestroyNotify _tmp1_ = NULL;
VoidFunc _tmp2_;
_tmp2_ = get_void_func (&_tmp0_, &_tmp1_);
self->func = _tmp2_;
self->func_target = self;
self->func_target_destroy_notify = NULL;
}
// ...