Obviously you can't cast an instance of a base class to a superclass. You can do: var a = new TestSubType(); TestBase b = (TestBase)a;
Not viceversa. On Sun, Feb 5, 2017 at 6:30 PM, Al Thomas via vala-list <vala-list@gnome.org> wrote: > > >> ----- Original Message ----- > >> From: Daniel Brendle <grindh...@skarphed.org> >> Sent: Sunday, 5 February 2017, 16:09 >> Subject: [Vala] Invalid cast Warnings > >> At the moment I deal with a series of warnings like these: > >> (process:3325): GLib-GObject-WARNING **: invalid cast from 'OParlSystem' >> to 'System' > >> I compiled a minimum example to trigger the issue here: > > >> https://0bin.net/paste/J0sgx2b2NJp6lTj8#QBfz-GUhWagsfGsF7nUqEn/8XneAiL9NhYNIdo8GRt6 > > > A simpler example is: > > void main () { > var a = new TestBase (); > TestSubType b = (TestSubType)a; > } > > class TestBase { > } > > class TestSubType:TestBase { > } > > The offending line in the resulting C code is: > > _tmp1_ = _test_base_ref0 (G_TYPE_CHECK_INSTANCE_CAST (a, TYPE_TEST_SUB_TYPE, > TestSubType)); > > It is G_TYPE_CHECK_INSTANCE_CAST (a, TYPE_TEST_SUB_TYPE, TestSubType) that is > generating the warning. > > > It needs further investigation as to why it's failing the check. > > Hopefully someone else will chip in with an answer. > > Al > _______________________________________________ > vala-list mailing list > vala-list@gnome.org > https://mail.gnome.org/mailman/listinfo/vala-list _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list