GNOME Bugzilla – Bug 676802
Can't override virtual signals from interfaces implemented by the parent
Last modified: 2012-12-17 17:19:20 UTC
The following should work: public interface DaInterface { public virtual signal void da_signal () { print ("yo!\n"); } } public class DaBase : DaInterface { public DaBase () { } } public class DaChild : DaBase { public DaChild () { } public override void da_signal () { print ("got ya!\n"); } } static int main () { var c = new DaChild(); c.da_signal (); return 0; } But all I get is foo.vala:13.2-13.31: error: DaChild.da_signal: no suitable method found to override public override void da_signal () { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`override` is used only to override a virtual method from a base class. It's never used to (re)implement an interface method. To (re)implement an interface, you don't need a modifier. Your code works if you drop `override`.
I forgot to mention that you also need to specify the interface in the child class. The correct test case is: public interface DaInterface { public virtual signal void da_signal () { print ("yo!\n"); } } public class DaBase : DaInterface { public DaBase () { } } public class DaChild : DaBase, DaInterface { public DaChild () { } public void da_signal () { print ("got ya!\n"); } } static int main () { var c = new DaChild(); c.da_signal (); return 0; }
commit 535feeeb06aa97079c03792f2af056f54c2b6172 Author: Jürg Billeter <j@bitron.ch> Date: Fri May 25 11:39:44 2012 +0200 Support virtual interface signals Fixes bug 676802.
*** Bug 690335 has been marked as a duplicate of this bug. ***