Bug 51522

Summary: Overload resolution fails for referenced assembly
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: Class1.cs - compile this to a separate assembly
Program.cs

Description Josh Peterson 2017-01-13 20:16:18 UTC
Created attachment 19335 [details]
Class1.cs - compile this to a separate assembly

We have the C# code that uses an interface with a number of overloads for a certain method. If that interface is defined in the same source file as the code that uses it, it compiles properly. If the interface is defined in an separate referenced assembly though, the C# compiler reports an error, indicating that the proper overload cannot be found.

To reproduce this:

1. Compile the attached Class1.cs to a separate assembly.
2. Compiler the attached Program.cs and reference the separate assembly (via -r:)

The following compiler error will occur:

D:\scratch\ScratchCSharpProject\ScratchCSharpProject\Program.cs(72,13): error CS1502: The best overloaded method match for `SeparateAssembly.IGenericAction<T1,T2>.AddAction(SeparateAssembly.IGenericAction)' has some invalid arguments
D:\scratch\ScratchCSharpProject\SeparateAssembly\bin\Debug\SeparateAssembly.dll (Location of the symbol related to previous error)
D:\scratch\ScratchCSharpProject\ScratchCSharpProject\Program.cs(72,23): error CS1503: Argument `#1' cannot convert `SeparateAssembly.IGenericAction<T2,T1>' expression to type `SeparateAssembly.IGenericAction'
Compilation failed: 2 error(s), 0 warnings

Note that if the commented-out code in Program.cs is used instead of the separate assembly, the problem will not occur. The Microsoft C# compiler compiles this code properly, so I think it is valid C# code.
Comment 1 Josh Peterson 2017-01-13 20:18:31 UTC
Created attachment 19336 [details]
Program.cs

This is the Program.cs file.
Comment 2 Marek Safar 2017-02-23 15:34:16 UTC
Fixed in master