[Mono-list] [patch] mcs and nested types

Miguel de Icaza miguel@ximian.com
08 Jan 2002 00:39:03 -0500

Hello Matt!

> mcs has compile errors with the following code:
>   using System;
>   public class outer {
> 	public class inner {
> 		public void meth(Object o) {
> 			inner inst = (inner)o;
> 		}
> 	}
>   }

Thanks for spotting this error.  I have included the above example in
the test suite now.

> This seems to be because RootContext.LookupType will only look for the "inner"
> type declared in the innermost class containing the compiled method.  Included
> is a patch against current CVS code, which fixes this problem:  LookupType will
> now cascade up the tree of containing types looking for the type name specified.
>  In order to implement this, I reorganized things so that DeclSpace objects
> always know their parents.  (Before, only TypeContainer objects knew their
> parents, not DeclSpace objects in general).

The fix is gorgeous, and it is the right way of fixing it.  Thanks for
taking the time to research it.  It is not really an obvious fix.

I have not yet commited it to CVS because my tree currently contains
some unfinished code.  I hope to commit the changes tomorrow morning.

Thanks a lot!