@@ -1349,10 +1349,14 @@ private Expression ParseInvocation(Expression expr, int errorPos, string error)
13491349 var args = ParseArgumentList ( ) ;
13501350
13511351 var invokeMethod = MemberFinder . FindInvokeMethod ( expr . Type ) ;
1352- if ( invokeMethod == null || ! MethodResolution . CheckIfMethodIsApplicableAndPrepareIt ( invokeMethod , args ) )
1353- throw ParseException . Create ( errorPos , error ) ;
1352+ if ( invokeMethod != null )
1353+ {
1354+ var invokeMethodData = MethodData . Gen ( invokeMethod ) ;
1355+ if ( MethodResolution . CheckIfMethodIsApplicableAndPrepareIt ( invokeMethodData , args ) )
1356+ return Expression . Invoke ( expr , invokeMethodData . PromotedParameters ) ;
1357+ }
13541358
1355- return Expression . Invoke ( expr , invokeMethod . PromotedParameters ) ;
1359+ throw ParseException . Create ( errorPos , error ) ;
13561360 }
13571361
13581362 private Expression ParseMethodGroupInvocation ( MethodGroupExpression methodGroup , int errorPos )
@@ -1378,7 +1382,7 @@ private Expression ParseMethodGroupInvocation(MethodGroupExpression methodGroup,
13781382 if ( args . Any ( IsDynamicExpression ) )
13791383 {
13801384 // TODO: we could try to find the best method by using the dynamic binder
1381- var candidatesWithSameArgumentCount = candidates . Where ( _ => _ . Method . Parameters . Count == args . Length ) . ToList ( ) ;
1385+ var candidatesWithSameArgumentCount = candidates . Where ( _ => _ . Method . GetParameters ( ) . Length == args . Length ) . ToList ( ) ;
13821386 if ( candidatesWithSameArgumentCount . Count == 1 )
13831387 return ParseDynamicMethodGroupInvocation ( candidatesWithSameArgumentCount [ 0 ] . Delegate , args ) ;
13841388 }
0 commit comments