diff --git a/src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/CompletionListTagCompletionProviderTests.vb b/src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/CompletionListTagCompletionProviderTests.vb index 089c81cfdcec192235cae80c4f630d28649a02f7..97f316ca70fb92430f47e5010108a62bcc0108dc 100644 --- a/src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/CompletionListTagCompletionProviderTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/CompletionListTagCompletionProviderTests.vb @@ -368,6 +368,33 @@ End Class VerifyNoItemsExist(markup) End Sub + + + Public Sub NotAfterInvocationWithCompletionListTagTypeAsFirstParameter() + Dim markup = +Public Class Type1 +End Class + +Public Class Type2 + Public Shared A As Type1 + Public Shared B As Type1 +End Class +]]>.Value + VerifyNoItemsExist(markup) + End Sub + + Friend Overrides Function CreateCompletionProvider() As CompletionListProvider Return New CompletionListTagCompletionProvider() End Function diff --git a/src/EditorFeatures/VisualBasicTest/TypeInferrer/TypeInferrerTests.vb b/src/EditorFeatures/VisualBasicTest/TypeInferrer/TypeInferrerTests.vb index 113826d1195d2588f54a100879daf43878f41103..601d2d605bb64504e06e750cf7033b3c9f33c726 100644 --- a/src/EditorFeatures/VisualBasicTest/TypeInferrer/TypeInferrerTests.vb +++ b/src/EditorFeatures/VisualBasicTest/TypeInferrer/TypeInferrerTests.vb @@ -710,5 +710,20 @@ Module M End Module" Test(text, "Global.System.Threading.Tasks.Task(Of System.Boolean)", testPosition:=True) End Sub + + + + Public Sub NoTypeAfterInvocationWithCompletionListTagTypeAsFirstParameter() + Dim text = "Class C + Sub Test() + M(5) + [|x|] + End Sub + + Sub M(x As Integer) + End Sub +End Class" + Test(text, "System.Object", testNode:=False, testPosition:=True) + End Sub End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb index adfa5ba390b0de358fcf86bb75651b89be4a5d82..74601db1858339ffe01e36900e59b1c80539327c 100644 --- a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb +++ b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicTypeInferenceService.TypeInferrer.vb @@ -217,6 +217,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic index = GetArgumentListIndex(argumentList, previousToken) End If + If index < 0 Then + Return SpecializedCollections.EmptyEnumerable(Of ITypeSymbol)() + End If + Dim info = _semanticModel.GetSymbolInfo(invocation) ' Check all the methods that have at least enough arguments to support being ' called with argument at this position. Note: if they're calling an extension @@ -259,6 +263,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Else index = GetArgumentListIndex(argumentList, previousToken) End If + + If index < 0 Then + Return SpecializedCollections.EmptyEnumerable(Of ITypeSymbol)() + End If + Dim constructors = namedType.InstanceConstructors.Where(Function(m) m.Parameters.Length > index) Return InferTypeInArgument(argumentOpt, index, constructors) End If @@ -279,6 +288,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic index = GetArgumentListIndex(argumentList, previousToken) End If + If index < 0 Then + Return SpecializedCollections.EmptyEnumerable(Of ITypeSymbol)() + End If + Dim info = _semanticModel.GetSymbolInfo(attribute) Dim symbols = info.GetBestOrAllSymbols() If symbols.Any() Then @@ -838,7 +851,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End If Dim index = argumentList.Arguments.GetWithSeparators().IndexOf(previousToken) - Return (index + 1) \ 2 + Return If(index >= 0, (index + 1) \ 2, -1) End Function Private Function InferTypeInCollectionInitializerExpression(