Revert "Fix bug #7829 - do NOT reject ConstructorInfo in DynamicILInfo.GetTokenFor()."
authorAtsushi Eno <atsushieno@veritas-vos-liberabit.com>
Sun, 18 Aug 2013 06:34:37 +0000 (15:34 +0900)
committerAtsushi Eno <atsushieno@veritas-vos-liberabit.com>
Sun, 18 Aug 2013 06:34:37 +0000 (15:34 +0900)
This reverts commit b43211d101e5e058b0d57e92a350515ffd71df26.

mcs/class/corlib/System.Reflection.Emit/DynamicILInfo.cs
mcs/class/corlib/System.Reflection.Emit/DynamicMethod.cs
mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
mcs/class/corlib/Test/System.Reflection.Emit/DynamicILInfoTest.cs
mono/metadata/reflection.c

index a3be40abcae2614e71a7d5d452a9cfad91956859..c086c63bd15be59bdd815103f4356af28233bdb2 100644 (file)
@@ -67,7 +67,7 @@ namespace System.Reflection.Emit {
                }
 
                public int GetTokenFor (RuntimeMethodHandle method) {
-                       MethodBase mi = MethodBase.GetMethodFromHandle (method);
+                       MethodInfo mi = (MethodInfo)MethodBase.GetMethodFromHandle (method);
                        return this.method.GetILGenerator ().TokenGenerator.GetToken (mi, false);
                }
 
index e7d02f1f16ef813487381fc3a54b5f647e1f90fd..b4915cced0454f49d01a199c18d40c1de134a084 100644 (file)
@@ -449,7 +449,7 @@ namespace System.Reflection.Emit {
                        return m.AddRef (str);
                }
 
-               public int GetToken (MethodBase method, Type[] opt_param_types) {
+               public int GetToken (MethodInfo method, Type[] opt_param_types) {
                        throw new InvalidOperationException ();
                }
 
index bc8b2538378428a3f993e62afc5a8840e373a851..b939ab6cffeba64c1c1cd0188b2dbf493841631d 100644 (file)
@@ -180,7 +180,7 @@ namespace System.Reflection.Emit {
 
                int GetToken (MemberInfo member, bool create_open_instance);
 
-               int GetToken (MethodBase method, Type[] opt_param_types);
+               int GetToken (MethodInfo method, Type[] opt_param_types);
 
                int GetToken (SignatureHelper helper);
        }               
index eab1cd0b8c9432cd6b7aa3d0191b03c36760429c..c3dd1f08bd0126986fbb0de1b97d9c237d458e8f 100644 (file)
@@ -656,7 +656,7 @@ namespace System.Reflection.Emit {
                private static extern int getToken (ModuleBuilder mb, object obj, bool create_open_instance);
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private static extern int getMethodToken (ModuleBuilder mb, MethodBase method,
+               private static extern int getMethodToken (ModuleBuilder mb, MethodInfo method,
                                                          Type[] opt_param_types);
 
                internal int GetToken (string str)
@@ -678,7 +678,7 @@ namespace System.Reflection.Emit {
                        return getToken (this, member, create_open_instance);
                }
 
-               internal int GetToken (MethodBase method, Type[] opt_param_types) {
+               internal int GetToken (MethodInfo method, Type[] opt_param_types) {
                        return getMethodToken (this, method, opt_param_types);
                }
 
@@ -981,7 +981,7 @@ namespace System.Reflection.Emit {
                        return mb.GetToken (member, create_open_instance);
                }
 
-               public int GetToken (MethodBase method, Type[] opt_param_types) {
+               public int GetToken (MethodInfo method, Type[] opt_param_types) {
                        return mb.GetToken (method, opt_param_types);
                }
 
index b70bb8405c36fede361c27b4b0c24111b5917a32..af33767c62f7c3f2df558004e6e437735391f58e 100644 (file)
@@ -62,14 +62,6 @@ public class DynamicILInfoTest
                var res = dm.Invoke(null, null);
                Assert.AreEqual ("abcd", res);
        }
-       
-       [Test] // bug #13969
-       public void GetTokenFor_Constructor () {
-               var m = typeof (object).GetConstructor (Type.EmptyTypes);
-               var dm = new DynamicMethod ("Foo", typeof (void), Type.EmptyTypes);
-               var dil = dm.GetDynamicILInfo ();
-               dil.GetTokenFor (m.MethodHandle);
-       }
 
        [Test]
        public void GetTokenFor_Type () {
index 993669915328e19d944d20038d30c2371c980757..1ddcb7fe33b5703e573f662612b1fca99afa476a 100644 (file)
@@ -4791,7 +4791,7 @@ mono_image_create_method_token (MonoDynamicImage *assembly, MonoObject *obj, Mon
        MonoMethodSignature *sig;
 
        klass = obj->vtable->klass;
-       if (strcmp (klass->name, "MonoMethod") == 0 || strcmp (klass->name, "MonoCMethod") == 0) {
+       if (strcmp (klass->name, "MonoMethod") == 0) {
                MonoMethod *method = ((MonoReflectionMethod *)obj)->method;
                MonoMethodSignature *old;
                guint32 sig_token, parent;