--- /dev/null
--- /dev/null
++// CS0120: `TestNamespace.TestClass.HelloWorld()': An object reference is required for the nonstatic field, method or property
++// Line: 31
++
++using System;
++using TestNamespace;
++
++namespace TestNamespace
++{
++ public class TestClass
++ {
++ public void HelloWorld ()
++ {
++ }
++ }
++}
++
++class SuperClass
++{
++ TestClass tc = null;
++
++ TestClass TestClass
++ {
++ get { return tc; }
++ }
++}
++
++class SubClass : SuperClass
++{
++ public SubClass ()
++ {
++ TestClass.HelloWorld ();
++ }
++}
++
++class App
++{
++ public static void Main ()
++ {
++ SubClass sc = new SubClass ();
++ }
++}
++2007-10-03 Raja R Harinath <rharinath@novell.com>
++
++ Fix #328490
++ * ecore.cs (SimpleName.DoSimpleNameResolve): Handle Property and
++ Event accessibility checks here. Remove some bogus code that
++ accidently made GenericMethods work.
++ (PropertyExpr.IsAccessibleFrom, EventExpr.IsAccessibleFrom): New.
++
2007-09-25 Marek Safar <marek.safar@gmail.com>
* expression.cs (ArrayCreation): Fixed cloning of an implicit types.
// Stage 2: Lookup members
//
-- DeclSpace lookup_ds = ec.DeclContainer;
Type almost_matched_type = null;
ArrayList almost_matched = null;
-- do {
++ for (DeclSpace lookup_ds = ec.DeclContainer; lookup_ds != null; lookup_ds = lookup_ds.Parent) {
++ // either RootDeclSpace or GenericMethod
if (lookup_ds.TypeBuilder == null)
-- break;
++ continue;
e = MemberLookup (ec.ContainerType, lookup_ds.TypeBuilder, Name, loc);
-- if (e != null)
-- break;
++ if (e != null) {
++ if (e is PropertyExpr) {
++ // since TypeManager.MemberLookup doesn't know if we're doing a lvalue access or not,
++ // it doesn't know which accessor to check permissions against
++ if (((PropertyExpr) e).IsAccessibleFrom (ec.ContainerType, right_side != null))
++ break;
++ } else if (e is EventExpr) {
++ if (((EventExpr) e).IsAccessibleFrom (ec.ContainerType))
++ break;
++ } else {
++ break;
++ }
++ e = null;
++ }
if (almost_matched == null && almostMatchedMembers.Count > 0) {
almost_matched_type = lookup_ds.TypeBuilder;
almost_matched = (ArrayList) almostMatchedMembers.Clone ();
}
--
-- lookup_ds =lookup_ds.Parent;
-- } while (lookup_ds != null);
--
-- if (e == null && ec.ContainerType != null)
-- e = MemberLookup (ec.ContainerType, ec.ContainerType, Name, loc);
++ }
if (e == null) {
if (almost_matched == null && almostMatchedMembers.Count > 0) {
Report.Error (1546, loc, "Property `{0}' is not supported by the C# language. Try to call the accessor method `{1}' directly",
Name, sig.ToString ());
}
--
++
++ public bool IsAccessibleFrom (Type invocation_type, bool lvalue)
++ {
++ bool dummy;
++ MethodInfo accessor = lvalue ? setter : getter;
++ if (accessor == null && lvalue)
++ accessor = getter;
++ return accessor != null && IsAccessorAccessible (invocation_type, accessor, out dummy);
++ }
++
override public Expression DoResolve (EmitContext ec)
{
if (resolved)
return true;
}
++ public bool IsAccessibleFrom (Type invocation_type)
++ {
++ bool dummy;
++ return IsAccessorAccessible (invocation_type, add_accessor, out dummy) &&
++ IsAccessorAccessible (invocation_type, remove_accessor, out dummy);
++ }
++
public override Expression DoResolveLValue (EmitContext ec, Expression right_side)
{
return DoResolve (ec);
--- /dev/null
--- /dev/null
++using System;
++using TestNamespace;
++
++namespace TestNamespace
++{
++ public class TestClass
++ {
++ public static void HelloWorld ()
++ {
++ }
++ }
++}
++
++class SuperClass
++{
++ TestClass tc = null;
++
++ public TestClass TestClass
++ {
++ private get { return tc; }
++ set {}
++ }
++}
++
++class SubClass : SuperClass
++{
++ public SubClass ()
++ {
++ TestClass.HelloWorld ();
++ }
++}
++
++class App
++{
++ public static void Main ()
++ {
++ SubClass sc = new SubClass ();
++ }
++}