Bug 30973 - Incorrect CS0425 when generic base class implements non-generic interface method
Summary: Incorrect CS0425 when generic base class implements non-generic interface method
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.0.0
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-06-10 09:41 UTC by peter
Modified: 2015-10-28 16:34 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 peter 2015-06-10 09:41:11 UTC
Compiling the following:
	public class BaseClass<TSource> {
		public void DoStuff<TInput>( TInput stuff )
			where TInput: TSource {
		}
	}

	public class MyClass: BaseClass<TInterface>, MyInterface {

	}

	public interface TInterface {

	}

	public interface MyInterface {
		void DoStuff<TInput>( TInput stuff )
			where TInput: TInterface;
	}

Results in the following when compiled as "Mono/.NET 4.5" with Mono 4.0.1 in monodevelop 5.9.4 on Ubuntu 15.04.

error CS0425: The constraints for type parameter `TInput' of method `MonoTypeConstraintBug.BaseClass<MonoTypeConstraintBug.TInterface>.DoStuff<TInput>(TInput)' must match the constraints for type parameter `TInput' of interface method `MonoTypeConstraintBug.MyInterface.DoStuff<TInput>(TInput)'. Consider using an explicit interface implementation instead.

It compiles fine with VS2012/.NET 4.5.

I can see that several similar bug reports exists against earlier versions that are marked as "fixed in master" (for example https://bugzilla.xamarin.com/show_bug.cgi?id=22131 ), but at least it still seems to be a problem in 4.0.1.
Comment 1 Marek Safar 2015-06-16 11:57:21 UTC
Fixed in master
Comment 2 Victor 2015-10-28 16:34:45 UTC
This is NOT fixed in master (using Xamarin Studio 5.9.7 and Xamarin iOS 9.0.1)