[Mono-bugs] [Bug 79972][Nor] New - gmcs crash when pass an generic anonymous method to a constructor

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Nov 19 02:49:31 EST 2006

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by redforks at gmail.com.


--- shadow/79972	2006-11-19 02:49:31.000000000 -0500
+++ shadow/79972.tmp.4260	2006-11-19 02:49:31.000000000 -0500
@@ -0,0 +1,104 @@
+Bug#: 79972
+Product: Mono: Compilers
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: redforks at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: gmcs crash when pass an generic anonymous method to a constructor
+Pass an generic anonymous method to a constructor, like this:
+delegate void TestFunc<T>(T val);
+class A
+	public A(TestFunc<int> func) { }
+class TestClass
+	readonly A a = new A(delegate(int a) { });
+	static void Func<T>(TestFunc<T> func) { }
+gmcs will crash:
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+  at Mono.CSharp.AnonymousMethod.DoCreateMethodHost
+(Mono.CSharp.EmitContext ec) [0x00093] in
+  at Mono.CSharp.AnonymousContainer.Resolve (Mono.CSharp.EmitContext ec)
+[0x0012a] in /tmp/scratch/BUILD/mono-1.2/mcs/mcs/anonymous.cs:1246
+  at Mono.CSharp.AnonymousMethod.Resolve (Mono.CSharp.EmitContext ec)
+[0x00000] in /tmp/scratch/BUILD/mono-1.2/mcs/mcs/anonymous.cs:1379
+  at Mono.CSharp.AnonymousMethodExpression.Compatible
+(Mono.CSharp.EmitContext ec, System.Type delegate_type) [0x00321] in
+  at Mono.CSharp.Convert.ImplicitConversionStandard
+(Mono.CSharp.EmitContext ec, Mono.CSharp.Expression expr, System.Type
+target_type, Location loc) [0x001b2] in
+  at Mono.CSharp.Convert.ImplicitConversion (Mono.CSharp.EmitContext ec,
+Mono.CSharp.Expression expr, System.Type target_type, Location loc)
+[0x00012] in /tmp/scratch/BUILD/mono-1.2/mcs/mcs/convert.cs:1233
+  at Mono.CSharp.Invocation.VerifyArgumentsCompat (Mono.CSharp.EmitContext
+ec, System.Collections.ArrayList Arguments, Int32 arg_count,
+System.Reflection.MethodBase method, Boolean chose_params_expanded,
+System.Type delegate_type, Boolean may_fail, Location loc) [0x000b1] in
+  at Mono.CSharp.Invocation.OverloadResolve (Mono.CSharp.EmitContext ec,
+Mono.CSharp.MethodGroupExpr me, System.Collections.ArrayList Arguments,
+Boolean may_fail, Location loc) [0x00609] in
+  at Mono.CSharp.New.DoResolve (Mono.CSharp.EmitContext ec) [0x0033c] in
+  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec,
+ResolveFlags flags) [0x00067] in
+  at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext ec) [0x00000]
+in /tmp/scratch/BUILD/mono-1.2/mcs/mcs/ecore.cs:442
+  at Mono.CSharp.FieldBase.ResolveInitializer () [0x00022] in
+  at Mono.CSharp.ClassOrStruct.DefineFieldInitializers () [0x00025] in
+  at Mono.CSharp.ClassOrStruct.Define () [0x00000] in
+  at Mono.CSharp.RootContext.DefineTypes () [0x000e2] in
+  at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x0053e] in
+  at Mono.CSharp.Driver.Main (System.String[] args) [0x0001f] in
+And I made a patch: 
+Index: anonymous.cs
+--- anonymous.cs        (revision 68052)
++++ anonymous.cs        (working copy)
+@@ -1361,7 +1361,7 @@
+                                member_name = new MemberName (name, args,
+                                generic_method = new GenericMethod (
+-                                       RootScope.NamespaceEntry,
+RootScope, member_name,
++                                       RootScope != null ?
+RootScope.NamespaceEntry : null, RootScope, member_name,
+                                        new TypeExpression (ReturnType,
+Location), Parameters);
+                                generic_method.SetParameterInfo (null);

More information about the mono-bugs mailing list