From 56c5649f69cd31d31913404d5f05922f61b70344 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sat, 29 Oct 2011 17:13:45 +0200 Subject: [PATCH] GAsync: Don't pass generic arguments to .end() calls Fixes bug 661961. --- codegen/valaccodemethodcallmodule.vala | 6 ++++-- tests/Makefile.am | 1 + tests/asynchronous/bug661961.vala | 12 ++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/asynchronous/bug661961.vala 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 (); +} -- 2.47.2