Author: marek
Date: 2007-10-15 12:26:06 -0400 (Mon, 15 Oct 2007)
New Revision: 87520
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/class.cs
trunk/mcs/mcs/decl.cs
Log:
2007-10-15 Marek Safar <[EMAIL PROTECTED]>
* class.cs, decl.cs: Fixed overload members verification to do only one
check per possible collision.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-10-15 16:03:54 UTC (rev 87519)
+++ trunk/mcs/mcs/ChangeLog 2007-10-15 16:26:06 UTC (rev 87520)
@@ -1,3 +1,8 @@
+2007-10-15 Marek Safar <[EMAIL PROTECTED]>
+
+ * class.cs, decl.cs: Fixed overload members verification to do only one
+ check per possible collision.
+
2007-10-13 Marek Safar <[EMAIL PROTECTED]>
A fix for bug #325478
Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs 2007-10-15 16:03:54 UTC (rev 87519)
+++ trunk/mcs/mcs/class.cs 2007-10-15 16:26:06 UTC (rev 87520)
@@ -3476,31 +3476,30 @@
equal = false;
}
- if (equal) {
- //
- // Try to report 663: method only differs on
out/ref
- //
- Parameters info = ParameterInfo;
- Parameters other_info = method.ParameterInfo;
- for (int i = 0; i < info.Count; i++){
- if (info.ParameterModifier (i) !=
other_info.ParameterModifier (i)){
-
Report.SymbolRelatedToPreviousError (method);
- Report.Error (663, Location,
"`{0}': Methods cannot differ only on their use of ref and out on a parameters",
-
GetSignatureForError ());
- return false;
- }
+ if (!equal)
+ return false;
+
+ //
+ // Try to report 663: method only differs on out/ref
+ //
+ Parameters info = ParameterInfo;
+ Parameters other_info = method.ParameterInfo;
+ for (int i = 0; i < info.Count; i++) {
+ if (info.ParameterModifier (i) !=
other_info.ParameterModifier (i)) {
+ Report.SymbolRelatedToPreviousError
(method);
+ Report.Error (663, Location, "`{0}':
Methods cannot differ only on their use of ref and out on a parameters",
+ GetSignatureForError
());
+ return false;
}
+ }
- Report.SymbolRelatedToPreviousError (method);
- if (this is Operator && method is Operator)
- Report.Error (557, Location, "Duplicate
user-defined conversion in type `{0}'", Parent.Name);
- else
- Report.Error (111, Location,
TypeContainer.Error111, GetSignatureForError ());
+ Report.SymbolRelatedToPreviousError (method);
+ if (this is Operator && method is Operator)
+ Report.Error (557, Location, "Duplicate
user-defined conversion in type `{0}'", Parent.Name);
+ else
+ Report.Error (111, Location,
TypeContainer.Error111, GetSignatureForError ());
- return true;
- }
-
- return false;
+ return true;
}
//
@@ -4151,10 +4150,10 @@
GetSignatureForError ());
}
- public override bool MarkForDuplicationCheck ()
- {
- caching_flags |= Flags.TestMethodDuplication;
- return true;
+ public override bool IsOverloadable {
+ get {
+ return true;
+ }
}
public override string[] ValidAttributeTargets {
@@ -6335,7 +6334,8 @@
return false;
Report.SymbolRelatedToPreviousError (method);
- Report.Error (111, Location, TypeContainer.Error111,
method.GetSignatureForError ());
+ Report.Error (82, Location, "A member `{0}' is already
reserved",
+ method.GetSignatureForError ());
return true;
}
@@ -6651,10 +6651,10 @@
}
}
- public override bool MarkForDuplicationCheck ()
- {
- caching_flags |= Flags.TestMethodDuplication;
- return true;
+ public override bool IsOverloadable {
+ get {
+ return true;
+ }
}
protected bool CheckForDuplications ()
@@ -7631,9 +7631,9 @@
}
- public class Indexer : PropertyBase {
-
- class GetIndexerMethod : GetMethod
+ public class Indexer : PropertyBase
+ {
+ public class GetIndexerMethod : GetMethod
{
public GetIndexerMethod (PropertyBase method):
base (method)
@@ -7652,7 +7652,7 @@
}
}
- class SetIndexerMethod: SetMethod
+ public class SetIndexerMethod: SetMethod
{
public SetIndexerMethod (PropertyBase method):
base (method)
@@ -7864,10 +7864,10 @@
return sb.ToString ();
}
- public override bool MarkForDuplicationCheck ()
- {
- caching_flags |= Flags.TestMethodDuplication;
- return true;
+ public override bool IsOverloadable {
+ get {
+ return true;
+ }
}
protected override PropertyInfo ResolveBaseProperty ()
@@ -7994,7 +7994,7 @@
// imlicit and explicit operator of same types are not
allowed
if (OperatorType == OpType.Explicit || OperatorType ==
OpType.Implicit)
- MarkForDuplicationCheck ();
+ EnableOverloadChecks ();
if (!base.Define ())
return false;
Modified: trunk/mcs/mcs/decl.cs
===================================================================
--- trunk/mcs/mcs/decl.cs 2007-10-15 16:03:54 UTC (rev 87519)
+++ trunk/mcs/mcs/decl.cs 2007-10-15 16:26:06 UTC (rev 87520)
@@ -558,11 +558,17 @@
}
/// <summary>
- /// It helps to handle error 102 & 111 detection
+ /// Returns true when a member supports multiple overloads
(methods, indexers, etc)
/// </summary>
- public virtual bool MarkForDuplicationCheck ()
+ public virtual bool IsOverloadable {
+ get {
+ return false;
+ }
+ }
+
+ public void EnableOverloadChecks ()
{
- return false;
+ caching_flags |= Flags.TestMethodDuplication;
}
/// <summary>
@@ -756,8 +762,16 @@
return true;
}
- if (symbol.MarkForDuplicationCheck () &&
mc.MarkForDuplicationCheck ())
+ if (symbol.IsOverloadable && mc.IsOverloadable) {
+ //
+ // Enable both symbols check for indexers,
because we don't know which one came first
+ //
+ if (symbol is Indexer.SetIndexerMethod ||
symbol is Indexer.GetIndexerMethod)
+ mc.EnableOverloadChecks ();
+
+ symbol.EnableOverloadChecks ();
return true;
+ }
Report.SymbolRelatedToPreviousError (mc);
if ((mc.ModFlags & Modifiers.PARTIAL) != 0 && (symbol
is ClassOrStruct || symbol is Interface)) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches