merge -r 58060:58217
[mono.git] / mcs / gmcs / expression.cs
index 5bff44666518cf6a65594d196cae07ea30c9d212..3985cd5818cf8a0f8661dba3622bf71368784743 100644 (file)
@@ -4375,7 +4375,7 @@ namespace Mono.CSharp {
                         return !candidate_params && best_params;
                }
 
-               static bool IsOverride (MethodBase cand_method, MethodBase base_method)
+               internal static bool IsOverride (MethodBase cand_method, MethodBase base_method)
                {
                        if (!IsAncestralType (base_method.DeclaringType, cand_method.DeclaringType))
                                return false;
@@ -8115,6 +8115,21 @@ namespace Mono.CSharp {
                {
                        Indexers ix = empty;
 
+                       if (lookup_type.IsGenericParameter) {
+                               GenericConstraints gc = TypeManager.GetTypeParameterConstraints (lookup_type);
+                               if (gc == null)
+                                       return empty;
+
+                               if (gc.HasClassConstraint)
+                                       Append (ref ix, caller_type, GetIndexersForTypeOrInterface (caller_type, gc.ClassConstraint));
+
+                               Type[] ifaces = gc.InterfaceConstraints;
+                               foreach (Type itype in ifaces)
+                                       Append (ref ix, caller_type, GetIndexersForTypeOrInterface (caller_type, itype));
+
+                               return ix;
+                       }
+
                        Type copy = lookup_type;
                        while (copy != TypeManager.object_type && copy != null){
                                Append (ref ix, caller_type, GetIndexersForTypeOrInterface (caller_type, copy));