--- /dev/null
+// CS1540: Cannot access protected member `A.this[int]' via a qualifier of type `B'. The qualifier must be of type `C' or derived from it
+// Line: 14
+
+class A {
+ protected int this [int i] { get { return i; } }
+}
+
+class B : A { }
+
+class C : A {
+ static int Main ()
+ {
+ B b = new B ();
+ return b [0];
+ }
+}
+2010-03-02 Raja R Harinath <harinath@hurrynot.org>
+
+ * expression.cs (IndexerAccess.ResolveAccessor): Add CS1540 check.
+
2010-03-02 Marek Safar <marek.safar@gmail.com>
* cs-tokenizer.cs: Missed few locations in previous fix.
}
instance_expr.CheckMarshalByRefAccess (ec);
+
+ if (must_do_cs1540_check && (instance_expr != EmptyExpression.Null) &&
+ !TypeManager.IsInstantiationOfSameGenericType (instance_expr.Type, ec.CurrentType) &&
+ !TypeManager.IsNestedChildOf (ec.CurrentType, instance_expr.Type) &&
+ !TypeManager.IsSubclassOf (instance_expr.Type, ec.CurrentType)) {
+ ec.Report.SymbolRelatedToPreviousError (accessor.MetaInfo);
+ Error_CannotAccessProtected (ec, loc, accessor.MetaInfo, instance_expr.Type, ec.CurrentType);
+ return null;
+ }
+
eclass = ExprClass.IndexerAccess;
return this;
}