[vala/0.48] codegen: Add missing check while overriding virtual async interface methods



commit 495daaa6e92926e11596c0d4b65199955e4283db
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Nov 20 17:29:22 2021 +0100

    codegen: Add missing check while overriding virtual async interface methods
    
    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                 |  2 +-
 tests/objects/interface-virtual-override.vala | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 3fa26c235..ab0bd2503 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -184,7 +184,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;
diff --git a/tests/objects/interface-virtual-override.vala b/tests/objects/interface-virtual-override.vala
index 62fcb6597..827e2f944 100644
--- a/tests/objects/interface-virtual-override.vala
+++ b/tests/objects/interface-virtual-override.vala
@@ -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 ();
 }


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