[Mono-bugs] [Bug 46502][Nor] New - Interface constraint on class affects overloading resolution for indexers
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Thu, 17 Jul 2003 04:09:15 -0400 (EDT)
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 sestoft@dina.kvl.dk.
http://bugzilla.ximian.com/show_bug.cgi?id=46502
--- shadow/46502 Thu Jul 17 04:09:15 2003
+++ shadow/46502.tmp.24091 Thu Jul 17 04:09:15 2003
@@ -0,0 +1,76 @@
+Bug#: 46502
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: sestoft@dina.kvl.dk
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Interface constraint on class affects overloading resolution for indexers
+
+Description of Problem:
+
+Adding an interface constraint Seq : ISeq on class Seq changes overloading
+resolution for indexers, even in an expression where the interface is not used.
+
+Steps to reproduce the problem:
+1. Compile the program below
+
+using System;
+
+class Seq : ISeq {
+ public int this[int i] {
+ get { return i; }
+ }
+
+ public int[] this[params int[] ii] {
+ get { return new int[] { this[1], this[2], this[ii.Length] }; }
+ }
+}
+
+class TestSeq {
+ public static void Main(String[] args) {
+ Seq s4 = new Seq();
+ Console.WriteLine(s4[1]); // 1
+ int[] r = s4[2, 2, 1, 2, 0];
+ for (int i=0, stop=r.Length; i<stop; i++) // 1 2 5
+ Console.Write(r[i] + " ");
+ Console.WriteLine();
+ }
+}
+
+interface ISeq {
+ int this[int i] { get; }
+ int[] this[params int[] ii] { get; }
+}
+
+Actual Results:
+
+Bug7.cs(34) error CS0121: Ambiguous call when selecting function due to
+implicit casts
+Bug7.cs(34) error CS1501: No Overload for method `this' takes `5' arguments
+Compilation failed: 2 error(s), 0 warnings
+
+Expected Results:
+
+Should compile without problems; does with MS csc 1.1.
+
+How often does this happen?
+
+Always in mono 0.25.
+
+Additional Information:
+
+If the interface constraint ISeq is removed, everything is OK. The
+bytecode generated by MS csc 1.1 executes fine with mono 0.25, so the
+problem is in mcs. The process of interface mapping in mcs must have some
+weird side effect. There is no problem if only the int this[int] indexer
+is defined in Seq and ISeq.