- if (m is MethodBuilder)
- return true;
-
- MethodInfo base_method = m.GetBaseDefinition ();
- return base_method != m;
- }
-
- bool TryType (ResolveContext ec, Type t)
- {
- MethodGroupExpr mg = Expression.MemberLookup (ec.Compiler,
- ec.CurrentType, t, "GetEnumerator", MemberTypes.Method,
- Expression.AllBindingFlags, loc) as MethodGroupExpr;
- if (mg == null)
- return false;
-
- MethodInfo result = null;
- MethodInfo tmp_move_next = null;
- PropertyExpr tmp_get_cur = null;
- Type tmp_enumerator_type = enumerator_type;
- foreach (MethodInfo mi in mg.Methods) {
- if (TypeManager.GetParameterData (mi).Count != 0)
- continue;
-
- // Check whether GetEnumerator is public
- if ((mi.Attributes & MethodAttributes.Public) != MethodAttributes.Public)
- continue;
-
- if (IsOverride (mi))
- continue;
-
- enumerator_found = true;
-
- if (!GetEnumeratorFilter (ec, mi))
- continue;
-
- if (result != null) {
- if (TypeManager.IsGenericType (result.ReturnType)) {
- if (!TypeManager.IsGenericType (mi.ReturnType))
- continue;
-
- MethodBase mb = TypeManager.DropGenericMethodArguments (mi);
- ec.Report.SymbolRelatedToPreviousError (t);
- ec.Report.Error(1640, loc, "foreach statement cannot operate on variables of type `{0}' " +
- "because it contains multiple implementation of `{1}'. Try casting to a specific implementation",
- TypeManager.CSharpName (t), TypeManager.CSharpSignature (mb));
- return false;
- }
-
- // Always prefer generics enumerators
- if (!TypeManager.IsGenericType (mi.ReturnType)) {
- if (TypeManager.ImplementsInterface (mi.DeclaringType, result.DeclaringType) ||
- TypeManager.ImplementsInterface (result.DeclaringType, mi.DeclaringType))
- continue;
-
- ec.Report.SymbolRelatedToPreviousError (result);
- ec.Report.SymbolRelatedToPreviousError (mi);
- ec.Report.Warning (278, 2, loc, "`{0}' contains ambiguous implementation of `{1}' pattern. Method `{2}' is ambiguous with method `{3}'",
- TypeManager.CSharpName (t), "enumerable", TypeManager.CSharpSignature (result), TypeManager.CSharpSignature (mi));
- return false;
- }
- }
- result = mi;
- tmp_move_next = move_next;
- tmp_get_cur = get_current;
- tmp_enumerator_type = enumerator_type;
- if (mi.DeclaringType == t)
- break;