GNOME Bugzilla – Bug 614986
Problem with mixing generics and delegates
Last modified: 2018-05-22 13:31:47 UTC
Hi, The following example produces uncompilable code: public class GenericDelegate<T> : Object { public delegate T TestDelegate(); public TestDelegate test_closure { get; set; } } public int main() { var test = new GenericDelegate<string> (); test.test_closure = () => { return "hi"; }; print (test.test_closure()); return 0; } valac says: /home/quikee/Test.vala.c: In function ‘_lambda0_’: /home/quikee/Test.vala.c:171: warning: assignment makes pointer from integer without a cast /tmp/cc1AUEeh.o: In function `_lambda0_': Test.vala.c:(.text+0x654): undefined reference to `t_dup_func' collect2: ld returned 1 exit status error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s) Second example is even worse.. it produces an error in valac: public class GenericDelegate : Object { public delegate T TestDelegate<T> (); public TestDelegate test_closure { get; set; } } public int main() { var test = new GenericDelegate(); test.test_closure = () => { return "hi"; }; print (test.test_closure()); return 0; } valac says: # valac Test.vala ** ERROR:valasemanticanalyzer.c:2886:vala_semantic_analyzer_get_actual_type: assertion failed: (instance_type != NULL) Aborted (core dumped)
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/82.