Vala generates incorrect code in case of co-recursive definition with delegate
@mpiechotka
Submitted by Maciej Marcin Piechotka Link to original bug (#703710)
Description
Created attachment 248523 text/x-vala
Vala generates incorrect code in case of co-recursive definition with delegate. For example:
public delegate void F(Test t);
public interface Test {
public abstract void g(owned F f);
}
produces following code:
typedef struct _Test Test;
typedef struct _TestIface TestIface;
struct _TestIface {
GTypeInterface parent_iface;
void (*g) (Test* self, F f, void* f_target, GDestroyNotify f_target_destroy_notify);
};
typedef void (*F) (Test* t, void* user_data);
While it should put definition of F between typedef struct _TestIface TestIface
and struct _TestIface {
(to handle classes as well).
Similar problem is with co-recursive definition of delegates:
public delegate void G(H h);
public delegate void H(G g);
which results in following code:
typedef void (*H) (G g, void* g_target, void* user_data);
typedef void (*G) (H h, void* h_target, void* user_data);
Solution to this problem is less obvious (I believe such type would required equi-recursion in C type system).
Attachment 248523, "text/x-vala":
test.vala
Edited by Corentin Noël