|
Bugzilla – Full Text Bug Listing |
| Summary: | gmcs is confused by generics methods with the same name when one returns void | ||
|---|---|---|---|
| Product: | [Mono] Mono: Compilers | Reporter: | Jean-Baptiste Evain <jbevain> |
| Component: | C# | Assignee: | Marek Safar <msafar> |
| Status: | RESOLVED FIXED | QA Contact: | Mono Bugs <mono-bugs> |
| Severity: | Normal | ||
| Priority: | P5 - None | CC: | casey.s.marshall, juan.wajnerman |
| Version: | SVN | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Other | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
Fixed in SVN. I still have an issue with this, more complete repro:
--
using System;
class Program
{
static void Foo (Action<string> a)
{
a ("action");
}
static T Foo<T> (Func<string, T> f)
{
return f ("function");
}
static string Bar ()
{
return Foo (
str => str.ToLower ());
}
static void Main ()
{
var str = Foo (s => s);
Console.WriteLine (str);
Foo (s => Console.WriteLine (s));
}
}
--
The issue here is the Foo call in Bar. gmcs fails to find the appropriate Foo method while csc does.
Fixed in SVN. *** Bug 377822 has been marked as a duplicate of this bug. *** I don't think the fix in SVN is correct (it appears to cause bug 378189). The error message I get is: pr370577.cs(18,24): error CS0121: The call is ambiguous between the following methods or properties: `Program.Foo(System.Action<string>)' and `Program.Foo<string>(System.Func<string,string>)' pr370577.cs(6,21): (Location of the symbol related to previous error) pr370577.cs(11,18): (Location of the symbol related to previous error) Since Bar returns whatever 'Foo' returns, the compiler can't possibly choose 'void Foo(Action<string>)' as the correct function. The fix checked in for this seems to only check if the context returns void, that the invocation return void too. Fixed in SVN. |
Repro: using System; class Program { static void Foo (Action<string> a) { a ("action"); } static T Foo<T> (Func<string, T> f) { return f ("function"); } static void Main () { var str = Foo (s => s); Console.WriteLine (str); Foo (s => Console.WriteLine (s)); } }