[vala] GAsync: Don't pass generic arguments to .end() calls



commit f9a86732faa7c1065c1ec28cc4543684a2d0e26b
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Oct 29 17:13:45 2011 +0200

    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(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 04cecfd..fa3f727 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 682b128..4185195 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -143,6 +143,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 0000000..53feed3
--- /dev/null
+++ b/tests/asynchronous/bug661961.vala
@@ -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 ();
+}



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