[Mono-list] [ MCS Fix Patch ] expression.cs

yoros@wanadoo.es yoros@wanadoo.es
Thu, 23 Jan 2003 20:54:41 +0100


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


Hi,

Here I send a fix for a indexer bug in the inheritance. This fix is
tested in mono 0.19 and it works. In the current mcs from cvs there is a
problem with the Indexers but it is out of the file that I changed. The
patch is for "expression.cs".

I send a testcase too.

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

--vkogqOf2sHV7VnPd
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 -r1.396 expression.cs
6850a6851
> 			ArrayList AllGetters = new ArrayList();
6864,6881c6865,6868
< 
< 				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);
> 					}
6883d6869
< 
6884a6871,6876
> 			}
> 			if (AllGetters.Count > 0) {
> 				found_any = true;
> 				found_any_getters = true;
> 				get = (MethodInfo) Invocation.OverloadResolve (
> 					ec, new MethodGroupExpr (AllGetters, loc), arguments, loc);

--vkogqOf2sHV7VnPd
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]);
	}

}

--vkogqOf2sHV7VnPd--