]> 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>
Sat, 27 Jan 2018 20:17:22 +0000 (21:17 +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 dd8e916e202bdaea8596d5310e6a10a53bd85ff4..54df5239548e565032c015587648bf28a932f700 100644 (file)
@@ -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"));
index 77acc32e7f7a40e3dba8c9149e2d3a4188ca6be3..ac4eb10853d61ec00d81eb42220872ec09adb00a 100644 (file)
@@ -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 (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 ();
+}