[ilasm] Fix invalid codegen for method overloads with unique modop/modreq type only
[mono.git] / mcs / ilasm / codegen / MethodRef.cs
index 6c4e40e31dd1f95249dbce28595ea04d462b5f23..5c0553febf0424ae80cc9d05006118c9840ab77c 100644 (file)
@@ -13,47 +13,25 @@ using System.Collections;
 
 namespace Mono.ILASM {
 
-        public class MethodRef : IMethodRef {
-
-                private TypeRef owner;
-                private PEAPI.CallConv call_conv;
-                private ITypeRef ret_type;
-                private string name;
-                private ITypeRef[] param;
-
-                private PEAPI.Method peapi_method;
-                private bool is_resolved;
+        public class MethodRef : BaseMethodRef {
 
                 public MethodRef (TypeRef owner, PEAPI.CallConv call_conv,
-                        ITypeRef ret_type, string name, ITypeRef[] param)
+                        BaseTypeRef ret_type, string name, BaseTypeRef[] param, int gen_param_count)
+                        : base (owner, call_conv, ret_type, name, param, gen_param_count)
                 {
-                        this.owner = owner;
-                        this.call_conv = call_conv;
-                        this.ret_type = ret_type;
-                        this.name = name;
-                        this.param = param;
-                        is_resolved = false;
                 }
 
-                public PEAPI.Method PeapiMethod {
-                        get { return peapi_method; }
-                }
-
-               public PEAPI.CallConv CallConv {
-                       get { return call_conv; }
-                       set { call_conv = value; }
-               }
-
-               public ITypeRef Owner {
-                       get { return owner; }
-               }
-
-                public void Resolve (CodeGen code_gen)
+                public override void Resolve (CodeGen code_gen)
                 {
                         if (is_resolved)
                                 return;
 
+                       owner.Resolve (code_gen);
+
                         TypeDef owner_def = code_gen.TypeManager[owner.FullName];
+                       if (owner_def == null)
+                               Report.Error ("Reference to undefined class '" + owner.FullName + "'");
+
                         string write_name;
 
                         if (name == "<init>")
@@ -61,16 +39,13 @@ namespace Mono.ILASM {
                         else
                                 write_name = name;
 
-                        string sig;
-
                         if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
-                                sig = MethodDef.CreateSignature (ret_type, name, param);
-                                peapi_method = owner_def.ResolveMethod (sig, code_gen);
+                                peapi_method = owner_def.ResolveMethod (ret_type, call_conv, name, 
+                                        param, gen_param_count, code_gen);
                         } else {
-                                sig = MethodDef.CreateVarargSignature (ret_type, name, param);
                                 ArrayList opt_list = new ArrayList ();
                                 bool in_opt = false;
-                                foreach (ITypeRef type in param) {
+                                foreach (BaseTypeRef type in param) {
                                         if (type is SentinelTypeRef) {
                                                 in_opt = true;
                                         } else if (in_opt) {
@@ -78,8 +53,10 @@ namespace Mono.ILASM {
                                                 opt_list.Add (type.PeapiType);
                                         }
                                 }
-                                peapi_method = owner_def.ResolveVarargMethod (sig, code_gen,
-                                                (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
+                                peapi_method = owner_def.ResolveVarargMethod (
+                                                ret_type, call_conv, name, param, gen_param_count,
+                                                (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)),
+                                                code_gen);
                         }
 
                         is_resolved = true;