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.38.6~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc2b0ea03050760ede60bc56971081a9ce9a23b4;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 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 eedd5d5eb..e4e12403f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -299,6 +299,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 (); +}