]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix calling generic instance methods
authorJürg Billeter <j@bitron.ch>
Fri, 25 Sep 2009 09:16:53 +0000 (11:16 +0200)
committerJürg Billeter <j@bitron.ch>
Fri, 25 Sep 2009 09:16:53 +0000 (11:16 +0200)
Fixes bug 596246.

codegen/valaccodebasemodule.vala
codegen/valaccodemethodcallmodule.vala

index 25cdbe3d003802267f3c1d322117cd09eb1972bb..cd7dae6b60ba5ef67120075848308ae68c19fbd1 100644 (file)
@@ -3511,9 +3511,10 @@ internal class Vala.CCodeBaseModule : CCodeModule {
        public virtual void generate_error_domain_declaration (ErrorDomain edomain, CCodeDeclarationSpace decl_space) {
        }
 
-       public void add_generic_type_arguments (CCodeFunctionCall ccall, Gee.List<DataType> type_args, CodeNode expr, bool is_chainup = false) {
+       public void add_generic_type_arguments (Map<int,CCodeExpression> arg_map, Gee.List<DataType> type_args, CodeNode expr, bool is_chainup = false) {
+               int type_param_index = 0;
                foreach (var type_arg in type_args) {
-                       ccall.add_argument (get_type_id_expression (type_arg, is_chainup));
+                       arg_map.set (get_param_pos (0.1 * type_param_index + 0.01), get_type_id_expression (type_arg, is_chainup));
                        if (requires_copy (type_arg)) {
                                var dup_func = get_dup_func_expression (type_arg, type_arg.source_reference, is_chainup);
                                if (dup_func == null) {
@@ -3521,12 +3522,13 @@ internal class Vala.CCodeBaseModule : CCodeModule {
                                        expr.error = true;
                                        return;
                                }
-                               ccall.add_argument (new CCodeCastExpression (dup_func, "GBoxedCopyFunc"));
-                               ccall.add_argument (get_destroy_func_expression (type_arg, is_chainup));
+                               arg_map.set (get_param_pos (0.1 * type_param_index + 0.02), new CCodeCastExpression (dup_func, "GBoxedCopyFunc"));
+                               arg_map.set (get_param_pos (0.1 * type_param_index + 0.03), get_destroy_func_expression (type_arg, is_chainup));
                        } else {
-                               ccall.add_argument (new CCodeConstant ("NULL"));
-                               ccall.add_argument (new CCodeConstant ("NULL"));
+                               arg_map.set (get_param_pos (0.1 * type_param_index + 0.02), new CCodeConstant ("NULL"));
+                               arg_map.set (get_param_pos (0.1 * type_param_index + 0.03), new CCodeConstant ("NULL"));
                        }
+                       type_param_index++;
                }
        }
 
@@ -3587,12 +3589,12 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 
                        generate_type_declaration (expr.type_reference, source_declarations);
 
+                       var carg_map = new HashMap<int,CCodeExpression> (direct_hash, direct_equal);
+
                        if (cl != null && !cl.is_compact) {
-                               add_generic_type_arguments (creation_call, expr.type_reference.get_type_arguments (), expr);
+                               add_generic_type_arguments (carg_map, expr.type_reference.get_type_arguments (), expr);
                        }
 
-                       var carg_map = new HashMap<int,CCodeExpression> (direct_hash, direct_equal);
-
                        bool ellipsis = false;
 
                        int i = 1;
index 70483eff77bd1b9ce8549d7c11e7222c20670761..5baa63afe59512b453bd551b5d5e4d5d5d4a68ef 100644 (file)
@@ -108,13 +108,13 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                        foreach (DataType base_type in current_class.get_base_types ()) {
                                if (base_type.data_type is Class) {
-                                       add_generic_type_arguments (ccall, base_type.get_type_arguments (), expr, true);
+                                       add_generic_type_arguments (in_arg_map, base_type.get_type_arguments (), expr, true);
                                        break;
                                }
                        }
                } else if (m != null && m.get_type_parameters ().size > 0) {
                        // generic method
-                       add_generic_type_arguments (ccall, ma.get_type_arguments (), expr);
+                       add_generic_type_arguments (in_arg_map, ma.get_type_arguments (), expr);
                }
 
                // the complete call expression, might include casts, comma expressions, and/or assignments