@@ -818,15 +818,16 @@ private async Task<CSharpSyntaxNode> WithRemovedRedundantConversionOrNull(VBSynt
818818 public override async Task < CSharpSyntaxNode > VisitInvocationExpression (
819819 VBasic . Syntax . InvocationExpressionSyntax node )
820820 {
821- var invocationSymbol = _semanticModel . GetSymbolInfo ( node ) . ExtractBestMatch < IMethodSymbol > ( ) ;
822- var withinLocalFunction = RequiresLocalFunction ( node , invocationSymbol ) ;
821+ var invocationSymbol = _semanticModel . GetSymbolInfo ( node ) . ExtractBestMatch < ISymbol > ( ) ;
822+ var methodInvocationSymbol = invocationSymbol as IMethodSymbol ;
823+ var withinLocalFunction = methodInvocationSymbol != null && RequiresLocalFunction ( node , methodInvocationSymbol ) ;
823824 if ( withinLocalFunction ) {
824825 _additionalLocals . PushScope ( ) ;
825826 }
826827 try {
827828 var convertedInvocation = await ConvertInvocation ( node , invocationSymbol ) ;
828829 if ( withinLocalFunction ) {
829- return await HoistAndCallLocalFunction ( node , invocationSymbol , ( ExpressionSyntax ) convertedInvocation ) ;
830+ return await HoistAndCallLocalFunction ( node , methodInvocationSymbol , ( ExpressionSyntax ) convertedInvocation ) ;
830831 }
831832 return convertedInvocation ;
832833 } finally {
@@ -873,7 +874,7 @@ private async Task<CSharpSyntaxNode> ConvertInvocation(VBSyntax.InvocationExpres
873874 }
874875
875876 if ( expressionSymbol != null && expressionSymbol . IsKind ( SymbolKind . Property ) &&
876- invocationSymbol . GetParameters ( ) . Length == 0 ) {
877+ invocationSymbol != null && invocationSymbol . GetParameters ( ) . Length == 0 ) {
877878 return convertedExpression ; //Parameterless property access
878879 }
879880
@@ -941,8 +942,6 @@ private async Task<InvocationExpressionSyntax> HoistAndCallLocalFunction(VBSynta
941942
942943 private bool RequiresLocalFunction ( VBSyntax . InvocationExpressionSyntax invocation , IMethodSymbol invocationSymbol )
943944 {
944- if ( invocationSymbol == null ) return false ;
945-
946945 var originalArgsWithRefTypes = invocation . ArgumentList . Arguments
947946 . Select ( a => ( Arg : ( VBSyntax . SimpleArgumentSyntax ) a , RefType : GetRefType ( ( VBSyntax . SimpleArgumentSyntax ) a , invocation . ArgumentList , invocationSymbol . Parameters , out var argName , out var refKind ) , Name : argName , RefKind : refKind ) ) ;
948947
0 commit comments