Bug 51522 - Overload resolution fails for referenced assembly
Summary: Overload resolution fails for referenced assembly
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-01-13 20:16 UTC by Josh Peterson
Modified: 2017-02-23 15:34 UTC (History)
2 users (show)

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


Attachments
Class1.cs - compile this to a separate assembly (407 bytes, text/plain)
2017-01-13 20:16 UTC, Josh Peterson
Details
Program.cs (4.02 KB, text/plain)
2017-01-13 20:18 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-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