From: Luca Bruno Date: Sat, 29 Oct 2011 15:13:45 +0000 (+0200) Subject: GAsync: Don't pass generic arguments to .end() calls X-Git-Tag: 0.14.1~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56c5649f69cd31d31913404d5f05922f61b70344;p=thirdparty%2Fvala.git GAsync: Don't pass generic arguments to .end() calls Fixes bug 661961. --- diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 04cecfdcd..fa3f727f6 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -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); } diff --git a/tests/Makefile.am b/tests/Makefile.am index 9646dc36d..a2075018c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..53feed3e0 --- /dev/null +++ b/tests/asynchronous/bug661961.vala @@ -0,0 +1,12 @@ +public async T foo (T bar) { + return bar; +} + +void main () { + MainLoop loop = new MainLoop (); + foo.begin ("test", (s,r) => { + assert (foo.end (r) == "test"); + loop.quit (); + }); + loop.run (); +}