[Vala] New signal syntax is not 100% compatible with old



In the previous discusion
(http://mail.gnome.org/archives/vala-list/2009-May/msg00069.html)
Yu Feng notice me to test old signal syntax (+=) with inheritted signal.
I wrote small testcase to reproduce this feature (vala 0.7.2).

Is this bug?

-- 
Харин Роман <HarinRoman kranky-studio ru>
jabber://harinr jabber ru
// valac testcase.vala
class BaseClassWithSignal : Object {
    // test sygnal
    public signal void stiven();   
}

class InheritedClass : BaseClassWithSignal {
    public void some_very_usefull_method() {
        stdout.printf("** Usefull method\n");
    }
}

class TestClass : Object {
    private BaseClassWithSignal bc_obj;
    private InheritedClass in_obj;

    public TestClass() {
        // instance of base class
        bc_obj = new BaseClassWithSignal();
        bc_obj.stiven.connect(on_base_sygnal);
    
        // instance of inheritted class
        in_obj = new InheritedClass();
        
        // new sygnal syntax
        // error: Argument 1: Cannot convert from `TestClass.on_inh_sygnal' 
        // to `BaseClassWithSignal.stiven' 
        in_obj.stiven.connect(on_inh_sygnal); 

        // old sygnal syntax, this compilable
        //in_obj.stiven += on_inh_sygnal;
    }

    public void do_test() {
        // test base class
        stdout.printf("Emit sygnal BaseClassWithSignal\n");
        bc_obj.stiven();
        stdout.printf("Emit sygnal InheritedClass\n");
        in_obj.stiven();
    }

    void on_base_sygnal(BaseClassWithSignal obj) {
        stdout.printf(" >> handler BaseClassWithSignal\n");
    }

    void on_inh_sygnal(InheritedClass obj) {
        stdout.printf(" >> handler InheritedClass\n");
        obj.some_very_usefull_method();
    }
}

static int main (string[] args) {
    // base class
    var testclass = new TestClass();
    testclass.do_test();
    return 0;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]