Bug 18030 - Mono C# compiler incorrectly emits CS0277 for derived classes that define a property whose signature matches a property that the base class has defined via explicit interface implementation
Summary: Mono C# compiler incorrectly emits CS0277 for derived classes that define a p...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-02-26 14:11 UTC by emoriarty
Modified: 2014-05-07 09:10 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description emoriarty 2014-02-26 14:11:56 UTC
Summary of the issue 
- Interface IX<T> has indexer property (this[int])
- A<T> implements IX<T> and implements IX<T>.this[int] via explicit interface
implementation
- B<T> derives from A<T> and define its own this[int] with internal setter

===== Test.cs =====
     1	interface IX<T>
     2	{
     3	    T this[int index] { get; set; }
     4	}
     5	
     6	class A<T> : IX<T>
     7	{
     8	    // Explicit implementation of interface property
     9	    T IX<T>.this[int index]
    10	    {
    11	        get { throw new System.NotImplementedException(); }
    12	        set { throw new System.NotImplementedException(); }
    13	    }
    14	}
    15	
    16	class B<T> : A<T>
    17	{
    18	    public T this[int index]
    19	    {
    20	        get { throw new System.NotImplementedException(); }
    21	        internal set { throw new System.NotImplementedException(); }
    22	    }
    23	}
===== End of Test.cs =====

===== csc output =====
# From Visual Studio 2013 command prompt
$ csc /target:library Test.cs
Microsoft (R) Visual C# Compiler version 12.0.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.


===== mcs output =====
$ mcs --version
Mono C# compiler version 3.2.6.0
Test.cs(21,18): error CS0277: Accessor `B<T>.this[int].set' must be declared public to implement interface member `IX<T>.this[int].set'
Test.cs(3,30): (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings

This failed in the same manner on the following versions of mcs that I tested with.
mono-2.11.4.0
mono-3.0.0.0
mono-3.1.1.0
mono-3.2.6.0


Edward Moriarty | Junior Engineer
Coverity | The Leader in Development Testing
Comment 1 Marek Safar 2014-05-07 09:10:46 UTC
Fixed in master