From: Jürg Billeter Date: Sat, 20 Mar 2010 18:33:31 +0000 (+0100) Subject: Fix constructor chain up within the same class X-Git-Tag: 0.8.0~134 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a53e33de880ccfd59f4a3860426b977f21773e14;p=thirdparty%2Fvala.git Fix constructor chain up within the same class Fixes bug 603375. --- diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index f19bf514d..d36fbd4a6 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -130,10 +130,23 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule { } if (!current_class.is_compact) { - foreach (DataType base_type in current_class.get_base_types ()) { - if (base_type.data_type is Class) { - add_generic_type_arguments (in_arg_map, base_type.get_type_arguments (), expr, true); - break; + if (current_class != m.parent_symbol) { + // chain up to base class + foreach (DataType base_type in current_class.get_base_types ()) { + if (base_type.data_type is Class) { + add_generic_type_arguments (in_arg_map, base_type.get_type_arguments (), expr, true); + break; + } + } + } else { + // chain up to other constructor in same class + int type_param_index = 0; + var cl = (Class) m.parent_symbol; + foreach (TypeParameter type_param in cl.get_type_parameters ()) { + in_arg_map.set (get_param_pos (0.1 * type_param_index + 0.01), new CCodeIdentifier ("%s_type".printf (type_param.name.down ()))); + in_arg_map.set (get_param_pos (0.1 * type_param_index + 0.02), new CCodeIdentifier ("%s_dup_func".printf (type_param.name.down ()))); + in_arg_map.set (get_param_pos (0.1 * type_param_index + 0.03), new CCodeIdentifier ("%s_destroy_func".printf (type_param.name.down ()))); + type_param_index++; } } }