[Mono-bugs] [Bug 81948][Nor] New - [GMCS] compiler fail to resolve inherited generics property getter

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Jun 25 15:52:56 EDT 2007


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 giacomo.stelluti at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=81948

--- shadow/81948	2007-06-25 15:52:56.000000000 -0400
+++ shadow/81948.tmp.27310	2007-06-25 15:52:56.000000000 -0400
@@ -0,0 +1,93 @@
+Bug#: 81948
+Product: Mono: Compilers
+Version: 1.2
+OS: GNU/Linux [Other]
+OS Details: Gentoo 2006.1 - 2.6.18-r2 (x86 32-bit)
+Status: NEW   
+Resolution: 
+Severity: Unknown
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: giacomo.stelluti at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [GMCS] compiler fail to resolve inherited generics property getter
+
+Description of Problem:
+Say you want to extend a generic interface. I found the problem working
+with IEnumerator<T>.
+
+    interface IEnumeratorEx<T> : IEnumerator<T> {
+        T Next { get; }
+
+        bool IsLast { get; }
+
+        T GetRemainingFromNext();
+    }
+
+Let's see an implementation of this interface (some code will be cutted for
+brevity).
+
+	internal sealed class StringEnumeratorEx : IEnumeratorEx<string> {
+		public StringEnumeratorEx(string[] value) { [...] }
+
+		public string Current {
+			get {
+				[...]
+				return "elaboration result";
+			}
+		}
+
+        	object IEnumerator.Current {
+            		get {
+				return this.Current;
+			}
+        	}
+
+		public string Next { get { [...] } }
+
+		public bool IsLast { get { [...] } }
+
+       		public void Reset() { [...] }
+
+		public bool MoveNext() { [...] }
+
+	        public string GetRemainingFromNext() { [...] }
+
+        	public void Dispose() { }
+	}
+
+
+
+Steps to reproduce the problem:
+1. Create a program including the code defined here.
+2. Replace the [...] with the minum for let the program 'compile'; in same
+cases none instructions will be ok, in others just return the correct type.
+3. Use the StringEnumeratorEx.Current property getter like this:
+
+	IEnumeratorEx<string> e = new StringEnumeratorEx(
+		new string[] {"hello", "mono", "!"});
+	e.MoveNext();
+	string part = e.Current.Substring(2);
+
+Actual Results:
+Compilation fails with this error message:
+YourFile.cs(R,C): error CS0117: `object' does not contain a definition for
+`Substring'
+
+Expected Results:
+Compilation success. Under Microsoft implementation of .NET this code compiles.
+The problem is that MONO compiler resolves the 'e.Current' expression with
+the IEnumerator interface explicit implementation (object
+IEnumerator.Current). 
+
+How often does this happen? 
+Deterministic: when these conditions are satisfied.
+
+Additional Information:
+IL disassembly produceded compiling with MS CSC Compiler:
+    L_002f: callvirt instance !0
+[mscorlib]System.Collections.Generic.IEnumerator`1<string>::get_Current()


More information about the mono-bugs mailing list