Bug 53290 - Compilation difference between mcs & csc in Mono 4.9
Summary: Compilation difference between mcs & csc in Mono 4.9
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2017-03-13 20:14 UTC by Jonathan Pryor
Modified: 2017-03-14 14:01 UTC (History)
1 user (show)

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

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:

Description Jonathan Pryor 2017-03-13 20:14:35 UTC
Consider the following code;

  using System.Threading.Tasks;
  class App {
    static void Foo ()
    static void Main ()
      var r = Task.Run (Foo);

It compiles without error with `mcs`. It fails with `csc` from Mono 4.9:

> bo.cs(11,22): error CS0121: The call is ambiguous between the following methods or properties: 'Task.Run(Action)' and 'Task.Run(Func<Task>)'

The same happens with TryRoslyn:


Is this a Roslyn bug? An `mcs` bug?

Related: What happens when the non-Roslyn .NET 4.5 CSC.EXE is used?
Comment 1 Jonathan Pryor 2017-03-13 22:14:59 UTC
> What happens when the non-Roslyn .NET 4.5 CSC.EXE is used?

This is most amusing:

> bo.cs(11,21): error CS0407: 'void App.Foo()' has the wrong return type

bo.cs(11,21) is:

> var t = Task.Run (Foo);
>                   ^

I think I misplaced my jaw somewhere...

This doesn't appear to be specific to `Task<T>` either; replacing `Task.Run()` with static methods which overload based on `Action` and `Func<int>` results in the same error.

Which leads me to think that CSC's type inferencing *sucks*.
Comment 2 Marek Safar 2017-03-14 14:01:26 UTC
Relevant Roslyn issue https://github.com/dotnet/roslyn/issues/8942