Bug 9776 - Ambiguity between interface member and base class member
Summary: Ambiguity between interface member and base class member
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2013-01-24 20:59 UTC by Paul Ryland
Modified: 2013-01-30 11:53 UTC (History)
1 user (show)

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:

Description Paul Ryland 2013-01-24 20:59:01 UTC
The following test code builds without error under Visual Studio/.NET4.0 but produces a compile error when built with MonoDevelop/Mono 2.10.9. It seems the compiler cannot reason that since 'T' must inherit both BaseClass and Interface2, that BaseClass.Id is the implementation of Interface1.Id.

using System;
namespace TestCS
	static class Program
		public interface Interface1
			int Id { get; }
		public interface Interface2 :Interface1
			int ExtraId { get; set; }
		public partial class BaseClass
			public int Id { get; set; }
		public class Derived :BaseClass ,Interface2
			public int ExtraId { get; set; }
			public Derived() { Id = 42; }
		private static void Generic<T>(T item) where T :BaseClass, Interface2
			// This line gives this error when compiled using Mono 2.10.9
			//   error CS0229: Ambiguity between `TestCS.Program.BaseClass.Id'
			//    and `TestCS.Program.Interface1.Id'
			// but does not give an error when built using Visual Studio 2010 and .NET4.0
			if (item.Id != 42) 
				throw new Exception("Doom!");
		static void Main() {}
Comment 1 Marek Safar 2013-01-30 11:53:56 UTC
Fixed in master