]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add missing check while overriding virtual async interface methods
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 20 Nov 2021 16:29:22 +0000 (17:29 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 20 Nov 2021 17:28:40 +0000 (18:28 +0100)
This fixes a couple of criticals and possibly faulty C code.

In addition to fc246aa7f8cbc6cb176724246a0187e19fe91198

See https://gitlab.gnome.org/GNOME/vala/issues/852

codegen/valagasyncmodule.vala
tests/objects/interface-virtual-override.vala

index 6c59c7fe479f82375ac03a7df1ebdae638549065..e59b6f03ffa078a25fe8db73afcc043d90771594 100644 (file)
@@ -205,7 +205,7 @@ public class Vala.GAsyncModule : GtkModule {
                if (m.overrides || (m.base_interface_method != null && !m.is_abstract && !m.is_virtual)) {
                        Method base_method;
 
-                       if (m.overrides) {
+                       if (m.overrides && m.base_method != null) {
                                base_method = m.base_method;
                        } else {
                                base_method = m.base_interface_method;
index 62fcb6597e8afaf6d72c2e9ce0a74ed2dff09090..827e2f944dbb87eedaceb87821d536957636c078 100644 (file)
@@ -2,15 +2,30 @@ interface IFoo : Object {
        public virtual int foo () {
                assert_not_reached ();
        }
+       public virtual async int bar () {
+               assert_not_reached ();
+       }
 }
 
 class Bar : Object, IFoo {
        public override int foo () {
                return 42;
        }
+       public override async int bar () {
+               return 23;
+       }
 }
 
+MainLoop loop;
+
 void main () {
        var bar = new Bar ();
        assert (bar.foo () == 42);
+
+       loop = new MainLoop ();
+       bar.bar.begin ((o,a) => {
+               assert (((Bar) o).bar.end (a) == 23);
+               loop.quit ();
+       });
+       loop.run ();
 }