Bug 28653

Summary: Invalid CS0311 error for overloaded generic method with dynamic parameter
Product: [Mono] Compilers Reporter: Alexander Köplinger <alex.koeplinger>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Tags: Is this bug a regression?: ---
Last known good build:

Description Alexander Köplinger 2015-04-01 14:41:27 UTC
The following code generates an error when compiled with mcs:

> namespace Test
> {
>     public class Program
>     {
>         public static int Main()
>         {
>             dynamic d = 0L;
>             return C.M<Program>(d);
>         }
>     }
> 
>     public class C
>     {
>         public static int M<T>(int i) where T : C
>         {
>             return 1;
>         }
> 
>         public static int M<T>(long l)
>         {
>             return 0;
>         }
>     }
> }


> $ mcs test.cs 
> test.cs(8,22): error CS0311: The type `Test.Program' cannot be used as type parameter `T' in the generic type or method `Test.C.M<T>(int)'. There is no implicit reference conversion from `Test.Program' to `Test.C'
> test.cs(14,29): (Location of the symbol related to previous error)
> Compilation failed: 1 error(s), 0 warnings

Note: this was extracted from the dynamics testsuite over at dotnet/corefx
Comment 1 Marek Safar 2015-04-02 11:36:14 UTC
Fixed in master