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

kanato eylvisaker at physics.ucdavis.edu
Sat Dec 6 04:39:57 EST 2008


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.

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

-- 
View this message in context: http://www.nabble.com/Bug-in-gmcs-compilation-with-shadowed-base-class-member.-tp20868277p20868277.html
Sent from the Mono - Dev mailing list archive at Nabble.com.



More information about the Mono-devel-list mailing list