@@ -350,7 +350,8 @@ Expression ParseIn()
350350
351351 var args = new [ ] { left } ;
352352
353- if ( _methodFinder . FindMethod ( typeof ( IEnumerableSignatures ) , nameof ( IEnumerableSignatures . Contains ) , false , ref args , out MethodBase containsSignature ) != 1 )
353+ Expression nullExpressionReference = null ;
354+ if ( _methodFinder . FindMethod ( typeof ( IEnumerableSignatures ) , nameof ( IEnumerableSignatures . Contains ) , false , ref nullExpressionReference , ref args , out MethodBase containsSignature ) != 1 )
354355 {
355356 throw ParseError ( op . Pos , Res . NoApplicableAggregate , nameof ( IEnumerableSignatures . Contains ) , string . Join ( "," , args . Select ( a => a . Type . Name ) . ToArray ( ) ) ) ;
356357 }
@@ -1476,7 +1477,9 @@ Expression ParseLambdaInvocation(LambdaExpression lambda)
14761477 int errorPos = _textParser . CurrentToken . Pos ;
14771478 _textParser . NextToken ( ) ;
14781479 Expression [ ] args = ParseArgumentList ( ) ;
1479- if ( _methodFinder . FindMethod ( lambda . Type , nameof ( Expression . Invoke ) , false , ref args , out MethodBase _ ) != 1 )
1480+
1481+ Expression nullExpressionReference = null ;
1482+ if ( _methodFinder . FindMethod ( lambda . Type , nameof ( Expression . Invoke ) , false , ref nullExpressionReference , ref args , out MethodBase _ ) != 1 )
14801483 {
14811484 throw ParseError ( errorPos , Res . ArgsIncompatibleWithLambda ) ;
14821485 }
@@ -1625,7 +1628,7 @@ Expression ParseMemberAccess(Type type, Expression instance)
16251628 }
16261629
16271630 Expression [ ] args = ParseArgumentList ( ) ;
1628- switch ( _methodFinder . FindMethod ( type , id , instance == null , ref args , out MethodBase mb ) )
1631+ switch ( _methodFinder . FindMethod ( type , id , instance == null , ref instance , ref args , out MethodBase mb ) )
16291632 {
16301633 case 0 :
16311634 throw ParseError ( errorPos , Res . NoApplicableMethod , id , TypeHelper . GetTypeName ( type ) ) ;
@@ -1642,7 +1645,14 @@ Expression ParseMemberAccess(Type type, Expression instance)
16421645 throw ParseError ( errorPos , Res . MethodIsVoid , id , TypeHelper . GetTypeName ( method . DeclaringType ) ) ;
16431646 }
16441647
1645- return Expression . Call ( instance , method , args ) ;
1648+ if ( instance == null )
1649+ {
1650+ return Expression . Call ( null , method , args ) ;
1651+ }
1652+ else
1653+ {
1654+ return Expression . Call ( instance , method , args ) ;
1655+ }
16461656
16471657 default :
16481658 throw ParseError ( errorPos , Res . AmbiguousMethodInvocation , id , TypeHelper . GetTypeName ( type ) ) ;
@@ -1743,19 +1753,19 @@ Expression ParseEnumerable(Expression instance, Type elementType, string methodN
17431753 _it = outerIt ;
17441754 _parent = oldParent ;
17451755
1746- if ( isDictionary && _methodFinder . ContainsMethod ( typeof ( IDictionarySignatures ) , methodName , false , ref args ) )
1756+ if ( isDictionary && _methodFinder . ContainsMethod ( typeof ( IDictionarySignatures ) , methodName , false , null , ref args ) )
17471757 {
17481758 var method = type . GetMethod ( methodName ) ;
17491759 return Expression . Call ( instance , method , args ) ;
17501760 }
17511761
1752- if ( ! _methodFinder . ContainsMethod ( typeof ( IEnumerableSignatures ) , methodName , false , ref args ) )
1762+ if ( ! _methodFinder . ContainsMethod ( typeof ( IEnumerableSignatures ) , methodName , false , null , ref args ) )
17531763 {
17541764 throw ParseError ( errorPos , Res . NoApplicableAggregate , methodName , string . Join ( "," , args . Select ( a => a . Type . Name ) . ToArray ( ) ) ) ;
17551765 }
17561766
17571767 Type callType = typeof ( Enumerable ) ;
1758- if ( isQueryable && _methodFinder . ContainsMethod ( typeof ( IQueryableSignatures ) , methodName , false , ref args ) )
1768+ if ( isQueryable && _methodFinder . ContainsMethod ( typeof ( IQueryableSignatures ) , methodName , false , null , ref args ) )
17591769 {
17601770 callType = typeof ( Queryable ) ;
17611771 }
@@ -1951,7 +1961,7 @@ void CheckAndPromoteOperand(Type signatures, string opName, ref Expression expr,
19511961 {
19521962 Expression [ ] args = { expr } ;
19531963
1954- if ( ! _methodFinder . ContainsMethod ( signatures , "F" , false , ref args ) )
1964+ if ( ! _methodFinder . ContainsMethod ( signatures , "F" , false , null , ref args ) )
19551965 {
19561966 throw IncompatibleOperandError ( opName , expr , errorPos ) ;
19571967 }
@@ -1984,12 +1994,12 @@ void CheckAndPromoteOperands(Type signatures, TokenId opId, string opName, ref E
19841994 if ( nativeOperation != null )
19851995 {
19861996 // first try left operand's equality operators
1987- found = _methodFinder . ContainsMethod ( left . Type , nativeOperation , true , ref args ) ;
1997+ found = _methodFinder . ContainsMethod ( left . Type , nativeOperation , true , null , ref args ) ;
19881998 if ( ! found )
1989- found = _methodFinder . ContainsMethod ( right . Type , nativeOperation , true , ref args ) ;
1999+ found = _methodFinder . ContainsMethod ( right . Type , nativeOperation , true , null , ref args ) ;
19902000 }
19912001
1992- if ( ! found && ! _methodFinder . ContainsMethod ( signatures , "F" , false , ref args ) )
2002+ if ( ! found && ! _methodFinder . ContainsMethod ( signatures , "F" , false , null , ref args ) )
19932003 {
19942004 throw IncompatibleOperandsError ( opName , left , right , errorPos ) ;
19952005 }
0 commit comments