GNOME Bugzilla – Bug 518109
Unable to use methods which implement an interface as callbacks
Last modified: 2008-03-01 16:39:25 UTC
When attempting to use, as a callback, a method which implements an interface, the generated code will attempt to reference what the method name would have been, had it not been implementing an interface. Example follows: public interface Foo { public abstract bool poll(); } // Works if you remove Foo. class Bar : GLib.Object, Foo { public bool poll() { GLib.stdout.printf("."); return true; } construct { GLib.Timeout.add(1000, this.poll); } public static int main(string[] args) { var foobar = new Bar(); return 0; } } /* nemequ@desktop:~$ valac -o hurumpf --pkg glib-2.0 hurumpf.vala /tmp/cc4YFOCJ.o: In function `_bar_poll_gsource_func': hurumpf.c:(.text+0x159): undefined reference to `bar_poll' collect2: ld returned 1 exit status error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s) */
Confirming.
2008-03-01 Jürg Billeter <j@bitron.ch> * gobject/valaccodegenerator.vala: fix using interface methods as delegates, fixes bug 518109 * tests/delegates.vala: test interface methods as delegates Fixed in r1080.