+ this.base_method = base_method;
+ }
+
+ internal MethodOnTypeBuilderInst (MethodOnTypeBuilderInst gmd, Type[] typeArguments)
+ {
+ this.instantiation = gmd.instantiation;
+ this.base_method = gmd.base_method;
+ this.method_arguments = new Type [typeArguments.Length];
+ typeArguments.CopyTo (this.method_arguments, 0);
+ this.generic_method_definition = gmd;
+ }
+
+ internal MethodOnTypeBuilderInst (MethodInfo method, Type[] typeArguments)
+ {
+ this.instantiation = method.DeclaringType;
+ this.base_method = ExtractBaseMethod (method);
+ this.method_arguments = new Type [typeArguments.Length];
+ typeArguments.CopyTo (this.method_arguments, 0);
+ if (base_method != method)
+ this.generic_method_definition = method;
+ }
+
+ static MethodInfo ExtractBaseMethod (MethodInfo info)
+ {
+ if (info is MethodBuilder)
+ return info;
+ if (info is MethodOnTypeBuilderInst)
+ return ((MethodOnTypeBuilderInst)info).base_method;
+
+ if (info.IsGenericMethod)
+ info = info.GetGenericMethodDefinition ();
+
+ Type t = info.DeclaringType;
+ if (!t.IsGenericType || t.IsGenericTypeDefinition)
+ return info;
+
+ return (MethodInfo)t.Module.ResolveMethod (info.MetadataToken);
+ }
+
+ internal Type[] GetTypeArgs ()
+ {
+ if (!instantiation.IsGenericType || instantiation.IsGenericParameter)
+ return null;
+
+ return instantiation.GetGenericArguments ();