+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
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 ();
}
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 ();
// 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);
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)
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];
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>".
/// </summary>
static public string CSharpName (Type t)
{
- if (IsNullableType (t)) {
+ if (IsNullableType (t) && !t.IsGenericTypeDefinition) {
t = GetTypeArguments (t) [0];
return CSharpName (t) + "?";
}
static public bool IsOverride (MethodBase m)
{
- if (m.Mono_IsInflatedMethod)
- m = m.GetGenericMethodDefinition ();
+ m = DropGenericMethodArguments (m);
return m.IsVirtual &&
(m.Attributes & MethodAttributes.NewSlot) == 0 &&