[Mono-bugs] [Bug 566285] New: False compilation errors re: implementing ancestor interface

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Dec 20 04:24:20 EST 2009


http://bugzilla.novell.com/show_bug.cgi?id=566285

http://bugzilla.novell.com/show_bug.cgi?id=566285#c0


           Summary: False compilation errors re: implementing ancestor
                    interface
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.6.x
          Platform: Macintosh
        OS/Version: Mac OS X 10.6
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: Chuck.Esterbrook at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Created an attachment (id=333574)
 --> (http://bugzilla.novell.com/attachment.cgi?id=333574)
The small source file that produces the problem.

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US;
rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5

gmcs.exe gives 2 false compilation errors for the following code. Logically,
the code should compile, and Microsoft csc.exe from VS2008 does so.

This came up from an open source C# project that won't compile under Mono.

Although I'm on Mac, this does not look Mac specific.

Code:

using System;
using System.Collections;
using System.Collections.Generic;

interface IFoo : IEnumerable<Foo> {
}

class Foo : IFoo {

    List<Foo> _fooList = new List<Foo>();

    IEnumerator<Foo> IEnumerable<Foo>.GetEnumerator() { // errors
        return _fooList.GetEnumerator();
    }

    public IEnumerator GetEnumerator() {
        return _fooList.GetEnumerator();
    }

    public static void Main() {
    }

}

/* false compilation errors:

foo.cs(12,43): error CS0540: `Foo.IEnumerable<Foo>.GetEnumerator()': containing
type does not implement interface `System.Collections.Generic.IEnumerable<Foo>'

foo.cs(12,43): error CS0539:
`System.Collections.Generic.IEnumerable<Foo>.GetEnumerator' in explicit
interface declaration is not a member of interface

*/

.. end of code.

Note that if you explicitly add "IEnumerable<Foo>" to the "class Foo"
declaration, gmcs.exe will be satisfied. But it should not be necessary as far
as I know since "IEnumerable<Foo>" is an ancestor interface of "Foo".


Reproducible: Always

Steps to Reproduce:
1. Save above code to foo.cs
2. gmcs foo.cs

Actual Results:  
2 inappropriate compile-time error messages

Expected Results:  
No errors or warnings.
Program executes with no side effects.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list