[Mono-bugs] [Bug 35332][Min] New - Incorrect Error 1501 reported

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
9 Dec 2002 20:50:16 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by f_azi@hotmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=35332

--- shadow/35332	Mon Dec  9 15:50:16 2002
+++ shadow/35332.tmp.2482	Mon Dec  9 15:50:16 2002
@@ -0,0 +1,95 @@
+Bug#: 35332
+Product: Mono/MCS
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: f_azi@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Incorrect Error 1501 reported
+
+Description of Problem:
+The error 1501("No Overload for method `this' takes 'x' arguments" is 
+fired incorrectly.
+
+The problem can be reproduced using the following source code:namespace 
+ns1 {
+	public interface I1 {
+		double this[int p1,int p2] {
+			get;
+			set;
+		}
+	}
+
+	public interface I2 : I1 {
+		double this[int nIndex] {
+			get;
+			set;
+		}
+	}
+
+	public class TheClass {
+		protected I2 pI2;
+		void InitPtr(I2 p) {
+			pI2 = p;
+		}
+		void Start(int a, int b, double c) {
+			if (pI2 != null)
+				pI2[a, b] = c;
+		}
+	}
+}
+
+Additional Information:
+Using the snapshot of Dec 08, 2002.
+I think the problem is in Indexers.GetIndexersForType, if the first call 
+to 'GetIndexersForTypeOrInterface' returns some indexers it will not keep 
+looking for more, it just returns with what is been found so far. In this 
+case, the first call will find the indexer of I1, but this indexer has 
+only one parameter, and that is why it fail later on. If instead of 
+returning after the first call to 'GetIndexersForTypeOrInterface' we keep 
+searching for other possibilities, and we build a solution set, 
+eventually we will find the indexer in I2, and this will prevent the 
+error from been fired. Something like:
+
+static private MemberInfo [] GetIndexersForTypeOrInterface (Type 
+caller_type, Type lookup_type) 
+{
+    return TypeManager.MemberLookup (caller_type, caller_type, 
+        lookup_type,MemberTypes.Property,BindingFlags.Public |
+        BindingFlags.Instance | BindingFlags.DeclaredOnly, 
+        TypeManager.IndexerPropertyName (lookup_type));
+}
+		
+static public Indexers GetIndexersForType (Type caller_type, Type 
+lookup_type, Location loc) 
+{
+    Indexers ix = (Indexers) map [lookup_type];			
+    if (ix != null)
+        return ix;
+
+    ix = new Indexers();
+    ix.Add(GetIndexersForTypeOrInterface (caller_type, lookup_type)); 
+
+    Type [] ifaces = TypeManager.GetInterfaces (lookup_type);
+    if (ifaces != null)
+        foreach (Type itype in ifaces)
+            ix.Add(GetIndexersForTypeOrInterface (caller_type, itype));
+    if ((ix.getters != null && ix.getters.Count > 0) || (ix.setters != 
+null && ix.setters.Count > 0)){
+        map[lookup_type] = ix;
+        return ix;
+    }
+
+    return null;
+}
+where a new empty constructor is added to Indexers and Indexers.Add have 
+the code of the old constructor receiving the MemberInfo[]