From: Ernestas Kulik Date: Sat, 27 Jan 2018 13:42:56 +0000 (+0200) Subject: codegen: Fix return-type for cancelled async creation methods of classes X-Git-Tag: 0.34.15~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b4e5e29840bc04211218b989ceec8721f32d84c;p=thirdparty%2Fvala.git 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 --- diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala index c23a3a0a8..1e9748ec4 100644 --- a/codegen/valagasyncmodule.vala +++ b/codegen/valagasyncmodule.vala @@ -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")); diff --git a/tests/Makefile.am b/tests/Makefile.am index 45c3a3a47..95b1b7d94 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 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 (); +}