Fix DynamicInvoke when the delegate is closed over null
authorJb Evain <jbevain@gmail.com>
Mon, 18 Apr 2011 13:47:33 +0000 (15:47 +0200)
committerJb Evain <jbevain@gmail.com>
Mon, 18 Apr 2011 13:47:53 +0000 (15:47 +0200)
mcs/class/corlib/System/Delegate.cs

index bd71c46e487aa31bf4f2324940b3594fb060356c..d36aa03100b8157db925c3858b6a43ce30dac9be 100644 (file)
@@ -392,7 +392,7 @@ namespace System
                                method_info = m_target.GetType ().GetMethod (data.method_name, mtypes);
                        }
 
-                       if ((m_target != null) && Method.IsStatic) {
+                       if (Method.IsStatic && (args != null ? args.Length : 0) == Method.GetParameters ().Length - 1) {
                                // The delegate is bound to m_target
                                if (args != null) {
                                        object[] newArgs = new object [args.Length + 1];