Bug 324622 (MONO81948) - [GMCS] compiler fail to resolve inherited generics property getter
Summary: [GMCS] compiler fail to resolve inherited generics property getter
Status: RESOLVED FIXED
Alias: MONO81948
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Linux
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-25 22:52 UTC by Giacomo Stelluti Scala
Modified: 2010-04-29 09:29 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Source files, ms csc compiled assembly, helper scripts. (3.59 KB, application/zip)
2007-06-25 23:01 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:42:27 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>

Comment 2 Marek Safar 2010-04-29 09:29:23 UTC
Fixed in trunk.