- AParametersCollection invoke_pd = TypeManager.GetParameterData (invoke_mb);
-
-#if GMCS_SOURCE
- if (!is_method_definition && old_mg.type_arguments == null &&
- !TypeManager.InferTypeArguments (invoke_pd, ref mb))
- return null;
-#endif
- AParametersCollection pd = TypeManager.GetParameterData (mb);
-
- if (invoke_pd.Count != pd.Count)
- return null;
-
- for (int i = pd.Count; i > 0; ) {
- i--;
-
- Type invoke_pd_type = invoke_pd.Types [i];
- Type pd_type = pd.Types [i];
- Parameter.Modifier invoke_pd_type_mod = invoke_pd.FixedParameters [i].ModFlags;
- Parameter.Modifier pd_type_mod = pd.FixedParameters [i].ModFlags;
-
- invoke_pd_type_mod &= ~Parameter.Modifier.PARAMS;
- pd_type_mod &= ~Parameter.Modifier.PARAMS;
-
- if (invoke_pd_type_mod != pd_type_mod)
- return null;
-
- if (TypeManager.IsEqual (invoke_pd_type, pd_type))
- continue;
-
- if (IsTypeCovariant (new EmptyExpression (invoke_pd_type), pd_type))
- continue;
-
- return null;
- }
-
- Type invoke_mb_retval = ((MethodInfo) invoke_mb).ReturnType;
- Type mb_retval = ((MethodInfo) mb).ReturnType;
- if (TypeManager.TypeToCoreType (invoke_mb_retval) == TypeManager.TypeToCoreType (mb_retval))
- return mb;
-
- //if (!IsTypeCovariant (mb_retval, invoke_mb_retval))
- // return null;
-
- if (RootContext.Version == LanguageVersion.ISO_1)
- return null;
-
- return mb;
- }
-
- // <summary>
- // Verifies whether the invocation arguments are compatible with the
- // delegate's target method
- // </summary>
- public static bool VerifyApplicability (EmitContext ec, Type delegate_type, ref Arguments args, Location loc)
- {
- int arg_count;
-
- if (args == null)
- arg_count = 0;
- else
- arg_count = args.Count;
-
- MethodBase mb = GetInvokeMethod (ec.ContainerType, delegate_type);
- MethodGroupExpr me = new MethodGroupExpr (new MemberInfo [] { mb }, delegate_type, loc);
-
- AParametersCollection pd = TypeManager.GetParameterData (mb);
-
- int pd_count = pd.Count;
-
- bool params_method = pd.HasParams;
- bool is_params_applicable = false;
- bool is_applicable = me.IsApplicable (ec, ref args, arg_count, ref mb, ref is_params_applicable) == 0;
- if (args != null)
- arg_count = args.Count;
-
- if (!is_applicable && !params_method && arg_count != pd_count) {
- Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
- TypeManager.CSharpName (delegate_type), arg_count.ToString ());
- return false;
- }
-
- return me.VerifyArgumentsCompat (
- ec, ref args, arg_count, mb,
- is_params_applicable || (!is_applicable && params_method),
- false, loc);
- }
-
- public static string FullDelegateDesc (MethodBase invoke_method)