[vala/0.38] codegen: Fix return-type for cancelled async creation methods of classes



commit fc2b0ea03050760ede60bc56971081a9ce9a23b4
Author: Ernestas Kulik <ernestask gnome org>
Date:   Sat Jan 27 15:42:56 2018 +0200

    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

 codegen/valagasyncmodule.vala     |    1 +
 tests/Makefile.am                 |    1 +
 tests/asynchronous/bug792942.vala |   15 +++++++++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index dd8e916..54df523 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 eedd5d5..e4e1240 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 0000000..5104f05
--- /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 ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]