[Mono-bugs] [Bug 429081] New: Method overload resolution incorrectly generates CS0121 for unambiguous case
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Sep 23 06:09:18 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=429081
Summary: Method overload resolution incorrectly generates CS0121
for unambiguous case
Product: Mono: Compilers
Version: 1.9
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: marc.gravell at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: Community User
Description of Problem:
Ambiguous call reported [between int and long? overload], even though there is
a clear "best" (14.4.2.2) overload that doesn't involve an implicit conversion
Steps to reproduce the problem:
Code as below, compile with gmcs [compiles fine with csc].
Actual Results:
test.cs(25,25): error CS0121: The call is ambiguous between the following
method
s or properties: `Program.Average<Bar>(IDataProducer<Bar>, FooFunc<Bar,long?>)'
and `Program.Average<Bar>(IDataProducer<Bar>, FooFunc<Bar,int>)'
test.cs(29,33): (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
Expected Results:
Should compile, selecting the "int" overload.
How often does this happen?
Every time
Code:
using System;
// same as Func<,> - just named to avoid 3.5 confusion
delegate TResult FooFunc<TArg,TResult>(TArg arg);
interface IDataProducer<T> {
// implementation not needed to show error
}
interface IFuture<T> {
// implementation not needed to show error
}
// a POD-type with a value we will aggregate later
class Bar {
public int Value {get;set;}
}
static class Program {
static void Main()
{
// implementation not needed to show error
IDataProducer<Bar> data = null;
// throws CS0121 between "long?" and "int" overloads
var result = data.Average(x=>x.Value);
}
// Average overload for int
public static IFuture<double> Average<TSource>(
this IDataProducer<TSource> source,
FooFunc<TSource, int> selector)
{ // implementation not necessary to show bug
throw new NotImplementedException();
}
// Average overload for long?
public static IFuture<double?> Average<TSource>(
this IDataProducer<TSource> source,
FooFunc<TSource, long?> selector)
{ // implementation not necessary to show bug
throw new NotImplementedException();
}
}
--
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.
More information about the mono-bugs
mailing list