[vala/staging] codegen: Add missing check while overriding virtual async interface methods
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Add missing check while overriding virtual async interface methods
- Date: Sat, 20 Nov 2021 16:41:33 +0000 (UTC)
commit bac6e1f9012b2e365f0547c26889ce0494e37f16
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 2ca56b705..4f130946e 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -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;
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]