[Mono-bugs] [Bug 636017] New: Disparity between gmcs / microsoft csc: Ambiguity between field and method with same name

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Aug 31 17:42:31 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=636017

https://bugzilla.novell.com/show_bug.cgi?id=636017#c0


           Summary: Disparity between gmcs / microsoft csc: Ambiguity
                    between field and method with same name
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.4.x
          Platform: x86-64
        OS/Version: RHEL 5
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: len at netvalue.net.nz
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9pre)
Gecko/2008042908

This code compiles and runs under Microsoft csc, but mono (I am using 2.4.3)
cannot compile it. The problem is due to a method with the same name as the
field.

--------------------------
using System;

public abstract class Foo {
  public abstract long Length {get;}
}

public abstract class Bar : Foo {
  public override long Length {get{ return 1;}}
}

public abstract class Baz : Bar {
  public new abstract long Length();
}

public class B1 : Baz {
  public override long Length() { return 2;}
}

public class Test
{
  public static void Something(Baz baz) {
    Console.WriteLine("Length method: " +  baz.Length());
    Console.WriteLine("Length property: " +  ((Bar)baz).Length);
  }

  static void Main() {
    Something(new B1());
  }
}
-------------------------
In our case Foo is System.IO.Stream, and Bar and Baz are classes in a third
party library.





Reproducible: Always

Steps to Reproduce:
1.Compile the test case.
Actual Results:  
/home2/len/Test.cs(22,48): error CS0229: Ambiguity between `Foo.Length' and
`Bar.Length'
/home2/len/Test.cs(4,24): (Location of the symbol related to previous error)
/home2/len/Test.cs(22,48): error CS0122: `Baz.Length()' is inaccessible due to
its protection level
/home2/len/Test.cs(12,28): (Location of the symbol related to previous error)
Compilation failed: 2 error(s), 0 warnings


Expected Results:  
C:\Users\len>csc Test.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.4926
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.


(I originally attached this as comment to another bug mentioning multiple
fields with the same name, but in this case we have one field and one method,
so there should be no ambiguity).

-- 
Configure bugmail: https://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