[Mono-list] Patch file for expression.cs

yoros@wanadoo.es yoros@wanadoo.es
Sat, 25 Jan 2003 04:19:07 +0100


--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit


Hi,

Here is the patch file for expression.cs in -u format. I send the
testcase again. Ah, the fix works in 0.19 and in CVS (I had broken cvs
tree).

See you,

    Pedro

-- 
Pedro Martinez Juliá
\  yoros@terra.es
)|    yoros@wanadoo.es
/        http://yoros.cjb.net
Socio HispaLinux #311
Usuario Linux #275438 - http://counter.li.org
GnuPG public information:  pub  1024D/74F1D3AC
Key fingerprint = 8431 7B47 D2B4 5A46 5F8E  534F 588B E285 74F1 D3AC

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="expression.cs.patch"

Index: expression.cs
===================================================================
RCS file: /mono/mcs/mcs/expression.cs,v
retrieving revision 1.396
diff -u -r1.396 expression.cs
--- expression.cs	9 Jan 2003 22:24:40 -0000	1.396
+++ expression.cs	25 Jan 2003 03:12:36 -0000
@@ -6848,6 +6848,7 @@
 
 		public override Expression DoResolve (EmitContext ec)
 		{
+			ArrayList AllGetters = new ArrayList();
 			if (!CommonResolve (ec))
 				return null;
 
@@ -6861,27 +6862,18 @@
 			Type lookup_type = indexer_type;
 			while (lookup_type != null) {
 				ilist = Indexers.GetIndexersForType (current_type, lookup_type, loc);
-
-				if (ilist == null) {
-					lookup_type = lookup_type.BaseType;
-					continue;
-				}
-
-				found_any = true;
-
-				//
-				// Step 2: find the proper match
-				//
-				if (ilist.getters != null && ilist.getters.Count > 0) {
-					found_any_getters = true;
-					get = (MethodInfo) Invocation.OverloadResolve (
-						ec, new MethodGroupExpr (ilist.getters, loc), arguments, loc);
-
-					if (get != null)
-						break;
+				if (ilist != null) {
+					foreach (object o in ilist.getters) {
+						AllGetters.Add(o);
+					}
 				}
-
 				lookup_type = lookup_type.BaseType;
+			}
+			if (AllGetters.Count > 0) {
+				found_any = true;
+				found_any_getters = true;
+				get = (MethodInfo) Invocation.OverloadResolve (
+					ec, new MethodGroupExpr (AllGetters, loc), arguments, loc);
 			}
 
 			if (!found_any) {

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="testcase.cs"

using System;

class A {
	public object this[double x] {
		get { return 3*x; }
	}
}

class B : A {
	public new object this[double x] {
		get { return x; }
	}
}

class C : B{
	public object this[string s] {
		get { return s; }
	}
	public object this[int x] {
		get { return x; }
	}
}

struct EntryPoint {

	public static void Main (string[] args) {
		C test = new C();
		Console.WriteLine("Double (333.333): "+test[333.333]);
		Console.WriteLine("String (a string): "+test["a string"]);
		Console.WriteLine("Integer (111): "+test[111]);
	}

}

--OXfL5xGRrasGEqWY--