[Mono-dev] Bug in gmcs compilation with shadowed base class member.

Marek Safar marek.safar at seznam.cz
Sun Dec 7 04:54:43 EST 2008


Hello,
> I found this piece of code which compiles under .NET (VS 2008) but not under
> gmcs.  gmcs gives a compilation error on the line calling a.field, saying
> that it is inaccessible since it's private.  However, Visual Studio maps
> a.field onto the Base class method.  The compiler I tried this with is
> version 2.0.1.
>   
Please fill a compiler bug report for this issue.

Thanks
Marek

> using System;
>
> public class Base
> {
>     public int field
> 	{ 
> 		get { Console.WriteLine("Got from class X."); return 0; }
> 	}
> }
> public class Derived : Base
> {
>     private new int field
> 	{
> 		get { Console.WriteLine("Got from class Y."); return 1; }
> 	}
> }
>
> public class MainClass
> {
> 	public static void Main()
> 	{
>         Derived a = new Derived();
>
> 		Console.WriteLine("a = {0}", a.field);
> 	}
> }
>
>   



More information about the Mono-devel-list mailing list