After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 518109 - Unable to use methods which implement an interface as callbacks
Unable to use methods which implement an interface as callbacks
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.1.x
Other All
: Normal normal
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-02-22 18:53 UTC by Evan Nemerson
Modified: 2008-03-01 16:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Evan Nemerson 2008-02-22 18:53:45 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)
*/
Comment 1 Raffaele Sandrini 2008-02-24 10:58:00 UTC
Confirming.
Comment 2 Jürg Billeter 2008-03-01 16:39:25 UTC
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.