https://bugzilla.novell.com/show_bug.cgi?id=633108
https://bugzilla.novell.com/show_bug.cgi?id=633108#c0 Summary: The call is ambiguous between the following methods or properties, when passing method as parameter. Classification: Mono Product: Mono: Compilers Version: 2.6.x Platform: All OS/Version: All Status: NEW Severity: Major Priority: P5 - None Component: C# AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8 I have brought a .NET 2.0 project over from visual studio which uses delegates and passes methods as parameters. I'm having trouble compiling it because when passing a method as an argument, the compiler cannot infer the method signature from the arguments used and as such does not distinguish between methods with different signatures. Assume this delegate: public delegate TResult Function<T, TResult>(T arg); Example, given these two method overloads: public static bool ParseBool(string value) { return ParseBool(value, "True", "False"); } public static bool ParseBool(string value, string trueValue = "true", string falseValue = "false", StringComparison comparisonType = StringComparison.InvariantCultureIgnoreCase) { if(trueValue.Equals(value, comparisonType)) return true; else if(falseValue.Equals(value, comparisonType)) return false; } Now if you have another method as such: T TryCatchHelper<T>(Function<string, T> converter, string value) { try { // attempt T to string conversion T result = converter(value); return result; } catch(Exception e) { // do stuff } } In my original project (VS2010/.NET 2.0) this gets compiled: bool result = TryCatchHelper(ParseBool, "true"); In Mono, it does not. First this creates a "Type cannot be inferred from usage" because it cannot identify that the generic type T is a boolean. So if I do: bool result = TryCatchHelper<bool>(ParseBool, "true"); Then I get that "The call is ambiguous between the following method or properties" and it lists the two ParseBool methods. It would be great if you had a look and fix this in the next versions. For now you have to workaround these problems. Thanks very much. Reproducible: Always Steps to Reproduce: Please use code above -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. You are the assignee for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
