On 11/11/2014 09:17 AM, Виталий Кирсанов wrote:
f.from(1);                         // this line causes the trouble
Your syntax is incorrect. This line should be:

f = new Foo.from (1);

The way you have written it, vala thinks Bar inherits from Foo. In the case where you call a base constructor, this will indeed be null until you call the base constructor.

public class Foo
{
    int i;

    public Foo.from(int i)
    {
        this.i = i;
    }
}

public class Bar : Foo
{
    public Bar()
    {
        assert( this != null ); // fails because `this` really is null here
        base.from(1);
        assert( this != null ); // succeeds
    }
}

int main(string[] argv)
{
    var b = new Bar();
    return 0;
}


_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to