[Mono-bugs] [Bug 33089][Nor] New - mcs complains when an indexer with different signature is declared in a derived class without "override"
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
31 Oct 2002 06:57:49 -0000
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by mathpup@mylinuxisp.com.
http://bugzilla.ximian.com/show_bug.cgi?id=33089
--- shadow/33089 Thu Oct 31 01:57:49 2002
+++ shadow/33089.tmp.29869 Thu Oct 31 01:57:49 2002
@@ -0,0 +1,86 @@
+Bug#: 33089
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details: SuSE Linux 8.0
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: mathpup@mylinuxisp.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mcs complains when an indexer with different signature is declared in a derived class without "override"
+
+Description of Problem:
+
+If I create a indexer in a base class with one signature and another indexer in a derived
+class, where the deriver class's indexer has a different signature, mcs complains that the
+second indexer hides the base indexer without using "override" or "new." See program
+below:
+
+using System;
+
+public class Base
+{
+ public virtual int this[ int x ]
+ {
+ get { return 5; }
+ set { ; }
+ }
+}
+
+
+public class Derived: Base
+{
+ public virtual int this[ int x, int y ]
+ {
+ get { return 6; }
+ set { ; }
+ }
+}
+
+
+public class Testing
+{
+ public static void Main()
+ {
+ Derived d = new Derived();
+
+ Console.WriteLine(d[4]);
+ }
+}
+
+
+
+Steps to reproduce the problem:
+1. Compile the program above.
+2.
+3.
+
+Actual Results:
+
+mcs shows an error: " this.cs(16) warning CS0114: `Derived.Item' hides inherited
+member `Base.this'. To make the current member override that implementation, add
+the override keyword, otherwise use the new keyword
+this.cs(29) error CS0154: indexer can not be used in this context, because it lacks a
+`get' accessor"
+
+
+Expected Results:
+
+No errors.
+
+
+How often does this happen?
+
+Always
+
+Additional Information:
+
+Changing "virtual" to "override" in the Derived.this[] indexer results in successful
+compilation, but I think that that behavior is incorrect and should actually cause an error.