瀏覽代碼

2008-02-26 Jb Evain <[email protected]>

	* Expression.cs (Call): Guess the parameters type from the argument
	types if needed.

svn path=/trunk/mcs/; revision=96662
Jb Evain 18 年之前
父節點
當前提交
4e8795f23e

+ 5 - 0
mcs/class/System.Core/System.Linq.Expressions/ChangeLog

@@ -1,3 +1,8 @@
+2008-02-26  Jb Evain  <[email protected]>
+
+	* Expression.cs (Call): Guess the parameters type from the argument
+	types if needed.
+
 2008-02-25  Jb Evain  <[email protected]>
 
 	* NewExpression.cs (Emit): deal with value types construction.

+ 4 - 6
mcs/class/System.Core/System.Linq.Expressions/Expression.cs

@@ -942,15 +942,14 @@ namespace System.Linq.Expressions {
 				throw new ArgumentNullException ("methodName");
 
 			if (typeArguments == null)
-				typeArguments = new Type [0];
+				typeArguments = (from arg in arguments select arg.Type).ToArray ();
 
 			var method = instance.Type.GetMethod (methodName, AllInstance, null, typeArguments, null);
 			if (method == null)
 				throw new InvalidOperationException ("No such method");
 
 			var args = arguments.ToReadOnlyCollection ();
-			if (typeArguments.Length != args.Count)
-				throw new InvalidOperationException ("Argument count doesn't match parameters length");
+			CheckMethodArguments (method, args);
 
 			return new MethodCallExpression (instance, method, args);
 		}
@@ -963,15 +962,14 @@ namespace System.Linq.Expressions {
 				throw new ArgumentNullException ("methodName");
 
 			if (typeArguments == null)
-				typeArguments = new Type [0];
+				typeArguments = (from arg in arguments select arg.Type).ToArray ();
 
 			var method = type.GetMethod (methodName, AllStatic, null, typeArguments, null);
 			if (method == null)
 				throw new InvalidOperationException ("No such method");
 
 			var args = arguments.ToReadOnlyCollection ();
-			if (typeArguments.Length != args.Count)
-				throw new InvalidOperationException ("Argument count doesn't match parameters length");
+			CheckMethodArguments (method, args);
 
 			return new MethodCallExpression (method, args);
 		}