Bug 52294 - C# compiler reports an incorrect error in a lambda with generic constraints
Summary: C# compiler reports an incorrect error in a lambda with generic constraints
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: 2017-02-03 17:43 UTC by Josh Peterson
Modified: 2017-02-20 16:20 UTC (History)
2 users (show)

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


Attachments
C# file to demonstrate the bug (711 bytes, text/plain)
2017-02-03 17:43 UTC, Josh Peterson
Details


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 Josh Peterson 2017-02-03 17:43:09 UTC
Created attachment 19718 [details]
C# file to demonstrate the bug

For the attached C# source code, the mcs compiler reports the following incorrect error:

gtest-lambda-38.cs(37,19): error CS0311: The type `Program.DerivedClass' cannot be used as type parameter `T' in the generic type or method `Program.DrerivedController.<VirtualMethod>__BaseCallProxy0<T,U>(U)'. There is no implicit reference conversion from `Program.DerivedClass' to `Program.BaseClass<U>'
gtest-lambda-38.cs(24,37): (Location of the symbol related to previous error)
gtest-lambda-38.cs(29,15): error CS0314: The type `T' cannot be used as type parameter `T' in the generic type or method `Program.BaseController.VirtualMethod<T,U>(U)'. There is no boxing or type parameter conversion from `T' to `Program.BaseClass<U>'
gtest-lambda-38.cs(24,37): (Location of the symbol related to previous error)

This code compiles correctly with the Microsoft C# compiler.

Note that if I change the code to use a method instead of a lambda, the code compiles correctly with mcs.
Comment 1 Marek Safar 2017-02-20 16:20:52 UTC
Fixed in master