summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-01-27 15:42:56 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2018-01-27 21:17:22 +0100
commit6c50cfbc2d45129c210fdb14da8be4fd91611743 (patch)
tree89bfb8f82fdafebb56858963e533156bdc650bc3
parent26ddc749ed5dc9d5953ce5e17eeab496e8ee467d (diff)
downloadvala-6c50cfbc2d45129c210fdb14da8be4fd91611743.tar.gz
codegen: Fix return-type for cancelled async creation methods of classes
While gcc just puts out a warning clang actually fails due to -Werror=return-type. https://bugzilla.gnome.org/show_bug.cgi?id=792942
-rw-r--r--codegen/valagasyncmodule.vala1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/asynchronous/bug792942.vala15
3 files changed, 17 insertions, 0 deletions
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index dd8e916e2..54df52395 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -601,6 +601,7 @@ public class Vala.GAsyncModule : GtkModule {
var type_sym = (TypeSymbol) m.parent_symbol;
if (type_sym is ObjectTypeSymbol) {
ccode.add_declaration (get_ccode_name (type_sym) + "*", new CCodeVariableDeclarator ("result"));
+ return_type = ((ObjectTypeSymbol) type_sym).get_this_type ();
}
} else if (!(return_type is VoidType) && !return_type.is_real_non_null_struct_type ()) {
ccode.add_declaration (get_ccode_name (m.return_type), new CCodeVariableDeclarator ("result"));
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 77acc32e7..ac4eb1085 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -304,6 +304,7 @@ TESTS = \
asynchronous/bug777242.vala \
asynchronous/bug783543.vala \
asynchronous/bug792660.vala \
+ asynchronous/bug792942.vala \
asynchronous/closures.vala \
asynchronous/generator.vala \
asynchronous/yield.vala \
diff --git a/tests/asynchronous/bug792942.vala b/tests/asynchronous/bug792942.vala
new file mode 100644
index 000000000..5104f05fa
--- /dev/null
+++ b/tests/asynchronous/bug792942.vala
@@ -0,0 +1,15 @@
+class Foo {
+ public async Foo () throws Error {
+ }
+}
+
+async void run () {
+ try {
+ var foo = yield new Foo ();
+ } catch {
+ }
+}
+
+void main () {
+ run.begin ();
+}