]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
GAsync: Don't pass generic arguments to .end() calls
authorLuca Bruno <lucabru@src.gnome.org>
Sat, 29 Oct 2011 15:13:45 +0000 (17:13 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 30 Nov 2011 13:43:27 +0000 (14:43 +0100)
Fixes bug 661961.

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

index 04cecfdcd1dcf365cdd3caef9136c51b5b2d879c..fa3f727f6f39081ea9c4faa77c581bcd7d08baa0 100644 (file)
@@ -30,6 +30,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                var ccall = new CCodeFunctionCall (get_cvalue (expr.call));
 
                CCodeFunctionCall async_call = null;
+               CCodeFunctionCall finish_call = null;
 
                Method m = null;
                Delegate deleg = null;
@@ -78,7 +79,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                        // async call
 
                        async_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
-                       var finish_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_finish_name (m)));
+                       finish_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_finish_name (m)));
 
                        if (ma.inner is BaseAccess) {
                                if (m.base_method != null) {
@@ -156,8 +157,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                        }
                } else if (m is CreationMethod && m.parent_symbol is Struct) {
                        ccall.add_argument (new CCodeIdentifier ("self"));
-               } else if (m != null && m.get_type_parameters ().size > 0 && !get_ccode_has_generic_type_parameter (m) && !get_ccode_simple_generics (m)) {
+               } else if (m != null && m.get_type_parameters ().size > 0 && !get_ccode_has_generic_type_parameter (m) && !get_ccode_simple_generics (m) && (ccall != finish_call || expr.is_yield_expression)) {
                        // generic method
+                       // don't add generic arguments for .end() calls
                        add_generic_type_arguments (in_arg_map, ma.get_type_arguments (), expr);
                }
 
index 9646dc36d27d1729c632559c4998636fb266fef4..a2075018cefc194c4db28c6857e0c2ca7a222bf6 100644 (file)
@@ -140,6 +140,7 @@ TESTS = \
        asynchronous/bug653861.vala \
        asynchronous/bug654336.vala \
        asynchronous/bug654337.vala \
+       asynchronous/bug661961.vala \
        asynchronous/closures.vala \
        dbus/basic-types.test \
        dbus/arrays.test \
diff --git a/tests/asynchronous/bug661961.vala b/tests/asynchronous/bug661961.vala
new file mode 100644 (file)
index 0000000..53feed3
--- /dev/null
@@ -0,0 +1,12 @@
+public async T foo<T> (T bar) {
+       return bar;
+}
+
+void main () {
+       MainLoop loop = new MainLoop ();
+       foo.begin ("test", (s,r) => {
+               assert (foo.end<string> (r) == "test");
+               loop.quit ();
+       });
+       loop.run ();
+}