[Mono-bugs] [Bug 463415] New: Wrong overloaded method is selected causing a compiler failure
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sat Jan 3 17:50:46 EST 2009
https://bugzilla.novell.com/show_bug.cgi?id=463415
Summary: Wrong overloaded method is selected causing a compiler
failure
Product: Mono: Compilers
Version: SVN
Platform: x86-64
OS/Version: Linux
Status: NEW
Severity: Major
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: mono at e-tobi.net
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Created an attachment (id=263086)
--> (https://bugzilla.novell.com/attachment.cgi?id=263086)
Sample Code
When compiling the following code, the compiler will choose the second
DoSomething() overload and then crashes. MS csc.exe correctly uses the first
DoSomething() method.
If I remove the first DoSomething(), gmcs crashes with the same failure. MS
csc.exe in this case gives an error CS0411 ("The type arguments for method
'method' cannot be inferred from the usage. Try specifying the type arguments
explicitly.")
Code:
public class Foo<T>
{
public void DoSomething(T value) {}
public void DoSomething<U>(Func<U, T> valueExpression) {}
}
public class Bar
{
protected void DoAnything<T, U>(U value)
{
new Foo<U>().DoSomething(value);
}
}
gmcs failure:
Exception caught by the compiler while compiling:
Block that caused the problem begin at: test.cs(11,20):
Block being compiled: [test.cs(12,5):,test.cs(14,5):]
System.ArgumentOutOfRangeException: Index is less than 0 or more than or equal
to the list count.
Parameter name: index
1
Internal compiler error at test.cs(11,20):: exception caught while emitting
MethodBuilder [Bar::DoAnything]
Unhandled Exception: System.ArgumentOutOfRangeException: Index is less than 0
or more than or equal to the list count.
Parameter name: index
1
at System.Collections.ArrayList.ThrowNewArgumentOutOfRangeException
(System.String name, System.Object actual, System.String message) [0x00000]
at System.Collections.ArrayList.set_Item (Int32 index, System.Object value)
[0x00000]
at Mono.CSharp.TypeInferenceContext.RemoveDependentTypes
(System.Collections.ArrayList types, System.Type returnType) [0x00000]
at Mono.CSharp.TypeInferenceContext.FixIndependentTypeArguments
(System.Type[] methodParameters, System.Boolean& fixed_any) [0x00000]
at Mono.CSharp.TypeInferenceV3.InferInPhases (Mono.CSharp.EmitContext ec,
Mono.CSharp.TypeInferenceContext tic, Mono.CSharp.AParametersCollection
methodParameters) [0x00000]
at Mono.CSharp.TypeInferenceV3.InferMethodArguments (Mono.CSharp.EmitContext
ec, System.Reflection.MethodBase method) [0x00000]
at Mono.CSharp.TypeManager.InferTypeArguments (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList arguments, System.Reflection.MethodBase& method)
[0x00000]
at Mono.CSharp.MethodGroupExpr.IsApplicable (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList arguments, Int32 arg_count,
System.Reflection.MethodBase& method, System.Boolean& params_expanded_form)
[0x00000]
at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList& Arguments, Boolean may_fail, Location loc)
[0x00000]
at Mono.CSharp.Invocation.DoResolveOverload (Mono.CSharp.EmitContext ec)
[0x00000]
at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext ec) [0x00000]
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec, ResolveFlags
flags) [0x00000]
at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000]
at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext
ec) [0x00000]
at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext ec)
[0x00000]
at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext ec) [0x00000]
at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext ec) [0x00000]
at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext
anonymous_method_host, Mono.CSharp.ToplevelBlock block, Mono.CSharp.Parameters
ip, IMethodData md, System.Boolean& unreachable) [0x00000]
--
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