]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix return-type for cancelled async creation methods of classes
authorErnestas Kulik <ernestask@gnome.org>
Sat, 27 Jan 2018 13:42:56 +0000 (15:42 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 30 Jan 2018 07:15:46 +0000 (08:15 +0100)
While gcc just puts out a warning clang actually fails due to
-Werror=return-type.

https://bugzilla.gnome.org/show_bug.cgi?id=792942

codegen/valagasyncmodule.vala
tests/Makefile.am
tests/asynchronous/bug792942.vala [new file with mode: 0644]

index c23a3a0a87b4fc2fd81b882805c5ad82ca53d73f..1e9748ec402b46ad0a806d3d4cc9113941f222cf 100644 (file)
@@ -514,6 +514,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"));
index 45c3a3a47c72ddee54a3323f1dc3cd2af3793efa..95b1b7d94ce3111a00d8f849a594d56626df6a6d 100644 (file)
@@ -239,6 +239,7 @@ TESTS = \
        asynchronous/bug742621.vala \
        asynchronous/bug762819.vala \
        asynchronous/bug792660.vala \
+       asynchronous/bug792942.vala \
        asynchronous/closures.vala \
        dbus/basic-types.test \
        dbus/arrays.test \
diff --git a/tests/asynchronous/bug792942.vala b/tests/asynchronous/bug792942.vala
new file mode 100644 (file)
index 0000000..5104f05
--- /dev/null
@@ -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 ();
+}