Bug 52294

Summary: C# compiler reports an incorrect error in a lambda with generic constraints
Product: [Mono] Compilers Reporter: Josh Peterson <joshuap>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: joshuap, mono-bugs+mono
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: C# file to demonstrate the bug

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