+
+ Type [] types = new Type [p_delegate_parameter_count];
+
+ //bool failure = false;
+ for (int j = 0; j < p_delegate_parameter_count; j++){
+ Type p_pt = p_delegate_parameters.ParameterType (j);
+
+ if (!p_pt.IsGenericParameter){
+ types [j] = p_pt;
+ continue;
+ }
+
+ //bool found = false;
+ for (int k = 0; k < method_generic_args.Length; k++){
+ if (method_generic_args [k] == p_pt){
+ types [j] = inferred_types [k];
+ break;
+ }
+ }
+ //
+ // If we could not infer just yet, continue
+ //
+ if (types [j] == null)
+ goto do_continue;
+ }
+
+ //
+ // If it results in a valid expression or statement block
+ //
+ Type lambda_inferred_type = le.TryBuild (ec, types);
+
+ if (lambda_inferred_type != null){
+ //
+ // Success, set the proper inferred_type value to the new type.
+ // return true
+ //
+ for (int k = 0; k < method_generic_args.Length; k++){
+ if (method_generic_args [k] == p_return_type){
+ inferred_types [k] = lambda_inferred_type;
+
+ lambdas.RemoveAt (i);
+ return true;
+ }
+ }
+ }