[vala/staging] codegen: Don't falsly use g_return_val_if_fail() for async creation method
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Don't falsly use g_return_val_if_fail() for async creation method
- Date: Sun, 27 Sep 2020 09:11:20 +0000 (UTC)
commit 07057c8cdd164223b70eafbef8b1db096df97974
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Sep 27 10:38:41 2020 +0200
codegen: Don't falsly use g_return_val_if_fail() for async creation method
Asynchronous creation methods are represented by 5 functions, "*_new",
"*_new_finish", "*_construct", "*_construct_co" and "*_construct_finish".
The argument checks are emitted in "*_construct" which is a void function
and cannot return any value.
Regression of 43f3e2ca534d082433fbe62aa347b7af443f9f33
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1077
codegen/valagtypemodule.vala | 2 +-
tests/Makefile.am | 1 +
tests/asynchronous/constructor-argument-check.vala | 13 +++++++++++++
3 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index daaa22b3a..8a8862a71 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -2410,7 +2410,7 @@ public class Vala.GTypeModule : GErrorModule {
cfile.add_include ("glib.h");
var cm = method_node as CreationMethod;
- if (cm != null && cm.parent_symbol is ObjectTypeSymbol) {
+ if (cm != null && !cm.coroutine && cm.parent_symbol is ObjectTypeSymbol) {
ccheck.call = new CCodeIdentifier ("g_return_val_if_fail");
ccheck.add_argument (new CCodeConstant ("NULL"));
} else if (ret_type is VoidType) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 817080efe..de02d1607 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -597,6 +597,7 @@ TESTS = \
asynchronous/catch-in-finally.vala \
asynchronous/creation-missing-yield.test \
asynchronous/closures.vala \
+ asynchronous/constructor-argument-check.vala \
asynchronous/finish-name.vala \
asynchronous/generator.vala \
asynchronous/out-parameter-invalid.test \
diff --git a/tests/asynchronous/constructor-argument-check.vala
b/tests/asynchronous/constructor-argument-check.vala
new file mode 100644
index 000000000..22238108a
--- /dev/null
+++ b/tests/asynchronous/constructor-argument-check.vala
@@ -0,0 +1,13 @@
+class Foo {
+ public async Foo (string bar) {
+ assert (bar == "foo");
+ }
+}
+
+async void run () {
+ yield new Foo ("foo");
+}
+
+void main () {
+ run.begin ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]