Bugzilla – Bug 324622
[GMCS] compiler fail to resolve inherited generics property getter
Last modified: 2010-04-29 09:29:23 UTC
---- Reported by giacomo.stelluti@gmail.com 2007-06-25 15:52:55 MST ---- 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() ---- Additional Comments From giacomo.stelluti@gmail.com 2007-06-25 16:01:49 MST ---- Created an attachment (id=172204) Source files, ms csc compiled assembly, helper scripts. Imported an attachment (id=172204) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Gentoo 2006.1 - 2.6.18-r2 (x86 32-bit)</cf_op_sys_details>
Fixed in trunk.