+
+ public bool CheckExistingMembersOverloads (MemberCore member, string name, Parameters parameters)
+ {
+ ArrayList entries = (ArrayList)member_hash [name];
+ if (entries == null)
+ return true;
+
+ int method_param_count = parameters.Count;
+ for (int i = entries.Count - 1; i >= 0; --i) {
+ CacheEntry ce = (CacheEntry) entries [i];
+
+ if (ce.Container != member.Parent.PartialContainer)
+ return true;
+
+ Type [] p_types;
+ ParameterData pd = null;
+ if ((ce.EntryType & EntryType.Property) != 0) {
+ p_types = TypeManager.GetArgumentTypes ((PropertyInfo) ce.Member);
+ } else {
+ MethodBase mb = (MethodBase) ce.Member;
+#if GMCS_SOURCE
+ // TODO: This is more like a hack, because we are adding generic methods
+ // twice with and without arity name
+ if (mb.IsGenericMethod && !member.MemberName.IsGeneric)
+ continue;
+#endif
+ pd = TypeManager.GetParameterData (mb);
+ p_types = pd.Types;
+ }
+
+ if (p_types.Length != method_param_count)
+ continue;
+
+ if (method_param_count > 0) {
+ int ii = method_param_count - 1;
+ Type type_a, type_b;
+ do {
+ type_a = parameters.ParameterType (ii);
+ type_b = p_types [ii];
+#if GMCS_SOURCE
+ if (type_a.IsGenericParameter && type_a.DeclaringMethod != null)
+ type_a = null;
+
+ if (type_b.IsGenericParameter && type_b.DeclaringMethod != null)
+ type_b = null;
+#endif
+ } while (type_a == type_b && ii-- != 0);
+
+ if (ii >= 0)
+ continue;
+
+ //
+ // Operators can differ in return type only
+ //
+ if (member is Operator) {
+ Operator op = TypeManager.GetMethod ((MethodBase) ce.Member) as Operator;
+ if (op != null && op.ReturnType != ((Operator) member).ReturnType)
+ continue;
+ }
+
+ //
+ // Report difference in parameter modifiers only
+ //
+ if (pd != null && !(member is AbstractPropertyEventMethod)) {
+ ii = method_param_count;
+ while (ii-- != 0 && parameters.ParameterModifier (ii) == pd.ParameterModifier (ii) &&
+ parameters.ExtensionMethodType == pd.ExtensionMethodType);
+
+ if (ii >= 0) {
+ MethodCore mc = TypeManager.GetMethod ((MethodBase) ce.Member) as MethodCore;
+ Report.SymbolRelatedToPreviousError (ce.Member);
+ if ((member.ModFlags & Modifiers.PARTIAL) != 0 && (mc.ModFlags & Modifiers.PARTIAL) != 0) {
+ if (parameters.HasParams || pd.HasParams) {
+ Report.Error (758, member.Location,
+ "A partial method declaration and partial method implementation cannot differ on use of `params' modifier");
+ } else {
+ Report.Error (755, member.Location,
+ "A partial method declaration and partial method implementation must be both an extension method or neither");
+ }
+ } else {
+ Report.Error (663, member.Location,
+ "An overloaded method `{0}' cannot differ on use of parameter modifiers only",
+ member.GetSignatureForError ());
+ }
+ return false;
+ }
+ }
+ }
+
+ if ((ce.EntryType & EntryType.Method) != 0) {
+ Method method_a = member as Method;
+ Method method_b = TypeManager.GetMethod ((MethodBase) ce.Member) as Method;
+ if (method_a != null && method_b != null && (method_a.ModFlags & method_b.ModFlags & Modifiers.PARTIAL) != 0) {
+ const int partial_modifiers = Modifiers.STATIC | Modifiers.UNSAFE;
+ if (method_a.IsPartialDefinition == method_b.IsPartialImplementation) {
+ if ((method_a.ModFlags & partial_modifiers) == (method_b.ModFlags & partial_modifiers) ||
+ method_a.Parent.IsInUnsafeScope && method_b.Parent.IsInUnsafeScope) {
+ if (method_a.IsPartialImplementation) {
+ method_a.SetPartialDefinition (method_b);
+ entries.RemoveAt (i);
+ } else {
+ method_b.SetPartialDefinition (method_a);
+ }
+ continue;
+ }
+
+ if ((method_a.ModFlags & Modifiers.STATIC) != (method_b.ModFlags & Modifiers.STATIC)) {
+ Report.SymbolRelatedToPreviousError (ce.Member);
+ Report.Error (763, member.Location,
+ "A partial method declaration and partial method implementation must be both `static' or neither");
+ }
+
+ Report.SymbolRelatedToPreviousError (ce.Member);
+ Report.Error (764, member.Location,
+ "A partial method declaration and partial method implementation must be both `unsafe' or neither");
+ return false;
+ }
+
+ Report.SymbolRelatedToPreviousError (ce.Member);
+ if (method_a.IsPartialDefinition) {
+ Report.Error (756, member.Location, "A partial method `{0}' declaration is already defined",
+ member.GetSignatureForError ());
+ }
+
+ Report.Error (757, member.Location, "A partial method `{0}' implementation is already defined",
+ member.GetSignatureForError ());
+ return false;
+ }
+
+ Report.SymbolRelatedToPreviousError (ce.Member);
+ IMethodData duplicate_member = TypeManager.GetMethod ((MethodBase) ce.Member);
+ if (member is Operator && duplicate_member is Operator) {
+ Report.Error (557, member.Location, "Duplicate user-defined conversion in type `{0}'",
+ member.Parent.GetSignatureForError ());
+ return false;
+ }
+
+ bool is_reserved_a = member is AbstractPropertyEventMethod || member is Operator;
+ bool is_reserved_b = duplicate_member is AbstractPropertyEventMethod || duplicate_member is Operator;
+
+ if (is_reserved_a || is_reserved_b) {
+ Report.Error (82, member.Location, "A member `{0}' is already reserved",
+ is_reserved_a ?
+ TypeManager.GetFullNameSignature (ce.Member) :
+ member.GetSignatureForError ());
+ return false;
+ }
+ } else {
+ Report.SymbolRelatedToPreviousError (ce.Member);
+ }
+
+ Report.Error (111, member.Location,
+ "A member `{0}' is already defined. Rename this member or use different parameter types",
+ member.GetSignatureForError ());
+ return false;
+ }
+
+ return true;
+ }