2006-02-14 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Tue, 14 Feb 2006 17:33:48 +0000 (17:33 -0000)
committerMartin Baulig <martin@novell.com>
Tue, 14 Feb 2006 17:33:48 +0000 (17:33 -0000)
* generic.cs
(TypeManager.DropGenericMethodArguments): New public method.
(TypeManager.IsInstantiatedMethod): New public method. Use this
instead of `Mono_IsInflatedMethod'.

svn path=/trunk/mcs/; revision=56861

mcs/gmcs/ChangeLog
mcs/gmcs/ecore.cs
mcs/gmcs/expression.cs
mcs/gmcs/generic.cs
mcs/gmcs/typemanager.cs

index ed230e0b4c6d751a9ff959d787e4bd50f99c236c..a9d32f73c4ab8d27dd4d1d19ab4081885fa136d3 100644 (file)
@@ -1,3 +1,10 @@
+2006-02-14  Martin Baulig  <martin@ximian.com>
+
+       * generic.cs
+       (TypeManager.DropGenericMethodArguments): New public method.
+       (TypeManager.IsInstantiatedMethod): New public method. Use this
+       instead of `Mono_IsInflatedMethod'.
+
 2006-02-14  Martin Baulig  <martin@ximian.com>
 
        * generic.cs
index 2ca674772a427b8e3f55f03d0ab11eea484b059c..9850292a8524b02d0e064c1473e4133aed344f54 100644 (file)
@@ -3513,9 +3513,7 @@ namespace Mono.CSharp {
                        FindAccessors (ec.ContainerType);
 
                        if (getter != null) {
-                               MethodInfo the_getter = getter;
-                               if (the_getter.Mono_IsInflatedMethod)
-                                       the_getter = the_getter.GetGenericMethodDefinition ();
+                               MethodBase the_getter = TypeManager.DropGenericMethodArguments (getter);
                                IMethodData md = TypeManager.GetMethod (the_getter);
                                if (md != null)
                                        md.SetMemberIsUsed ();
@@ -3525,9 +3523,7 @@ namespace Mono.CSharp {
                        }
 
                        if (setter != null) {
-                               MethodInfo the_setter = setter;
-                               if (the_setter.Mono_IsInflatedMethod)
-                                       the_setter = the_setter.GetGenericMethodDefinition ();
+                               MethodBase the_setter = TypeManager.DropGenericMethodArguments (setter);
                                IMethodData md = TypeManager.GetMethod (the_setter);
                                if (md != null)
                                        md.SetMemberIsUsed ();
index 3df82c0a196f7bd7e5692caf60d1012cb3472a40..b4f33caf4dfc363b7bdc6a9d7101cb91eee69cb9 100644 (file)
@@ -4419,10 +4419,8 @@ namespace Mono.CSharp {
                        // Pick the "more specific" signature
                        //
 
-                       MethodBase orig_candidate = candidate.Mono_IsInflatedMethod ?
-                               candidate.GetGenericMethodDefinition () : candidate;
-                       MethodBase orig_best = best.Mono_IsInflatedMethod ?
-                               best.GetGenericMethodDefinition () : best;
+                       MethodBase orig_candidate = TypeManager.DropGenericMethodArguments (candidate);
+                       MethodBase orig_best = TypeManager.DropGenericMethodArguments (best);
 
                        ParameterData orig_candidate_pd = TypeManager.GetParameterData (orig_candidate);
                        ParameterData orig_best_pd = TypeManager.GetParameterData (orig_best);
@@ -5016,14 +5014,10 @@ namespace Mono.CSharp {
                        if (method == null)
                                return null;
 
-                       MethodBase the_method = method;
-                       if (the_method.Mono_IsInflatedMethod) {
-                               the_method = the_method.GetGenericMethodDefinition ();
-
-                               if ((method is MethodInfo) &&
-                                   !ConstraintChecker.CheckConstraints (ec, the_method, method, loc))
-                                       return null;
-                       }
+                       MethodBase the_method = TypeManager.DropGenericMethodArguments (method);
+                       if (the_method.IsGenericMethodDefinition &&
+                           !ConstraintChecker.CheckConstraints (ec, the_method, method, loc))
+                               return null;
 
                        IMethodData data = TypeManager.GetMethod (the_method);
                        if (data != null)
index f66906ca3cc6d39b1919ac4f42949b4343c0d9ee..7c8d03345cb8e8704c6008ad2f1888e4f6b4e27f 100644 (file)
@@ -695,9 +695,7 @@ namespace Mono.CSharp {
                                        return false;
                                }
 
-                               MethodBase mb = implementing;
-                               if (mb.Mono_IsInflatedMethod)
-                                       mb = mb.GetGenericMethodDefinition ();
+                               MethodBase mb = TypeManager.DropGenericMethodArguments (implementing);
 
                                int pos = type.GenericParameterPosition;
                                Type mparam = mb.GetGenericArguments () [pos];
@@ -2035,6 +2033,22 @@ namespace Mono.CSharp {
                        return t.GetGenericTypeDefinition ();
                }
 
+               public static MethodBase DropGenericMethodArguments (MethodBase m)
+               {
+                       if ((m is MethodBuilder) || (m is ConstructorInfo))
+                               return m;
+                       if (m.IsGenericMethodDefinition)
+                               return m;
+                       if (m.IsGenericMethod || m.DeclaringType.IsGenericType)
+                               return m.GetGenericMethodDefinition ();
+                       return m;
+               }
+
+               public static bool IsInstantiatedMethod (MethodBase m)
+               {
+                       return m.IsGenericMethod || m.DeclaringType.IsGenericType;
+               }
+
                //
                // Whether `array' is an array of T and `enumerator' is `IEnumerable<T>'.
                // For instance "string[]" -> "IEnumerable<string>".
index f011c96bda6e80f6413ed2556f481a2c96f58385..83b5fc873f1dde7a580632785d5b3a93b5b84a7b 100644 (file)
@@ -591,7 +591,7 @@ public partial class TypeManager {
        /// </summary>
        static public string CSharpName (Type t)
        {
-               if (IsNullableType (t)) {
+               if (IsNullableType (t) && !t.IsGenericTypeDefinition) {
                        t = GetTypeArguments (t) [0];
                        return CSharpName (t) + "?";
                }
@@ -1789,8 +1789,7 @@ public partial class TypeManager {
 
        static public bool IsOverride (MethodBase m)
        {
-               if (m.Mono_IsInflatedMethod)
-                       m = m.GetGenericMethodDefinition ();
+               m = DropGenericMethodArguments (m);
 
                return m.IsVirtual &&
                        (m.Attributes & MethodAttributes.NewSlot) == 0 &&