Skip to content

Type inference does not handle index of IList<> #15811

@SeeminglyScience

Description

@SeeminglyScience

Steps to reproduce

$script = '([System.Collections.Generic.IList[System.Text.StringBuilder]]$null)[0].'
$results = TabExpansion2 -inputScript $script -cursorColumn $script.Length
$results.CompletionMatches

Note that changing IList to List in the above script will return the expected inferred members.

Expected behavior

CompletionText  ListItemText   ResultType ToolTip
--------------  ------------   ---------- -------
Capacity        Capacity         Property int Capacity { get; set; }
Length          Length           Property int Length { get; set; }
MaxCapacity     MaxCapacity      Property int MaxCapacity { get; }
Append(         Append             Method System.Text.StringBuilder Append(System.Char*, System.Private.CoreLib, Version=6.0.0.0, Culture=…
AppendFormat(   AppendFormat       Method System.Text.StringBuilder AppendFormat(string format, System.Object arg0)…
AppendJoin(     AppendJoin         Method System.Text.StringBuilder AppendJoin(string separator, Params System.Object[] values)…
AppendLine(     AppendLine         Method System.Text.StringBuilder AppendLine()…
Clear(          Clear              Method System.Text.StringBuilder Clear()
CopyTo(         CopyTo             Method void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)…
EnsureCapacity( EnsureCapacity     Method int EnsureCapacity(int capacity)
Equals(         Equals             Method bool Equals(System.Text.StringBuilder sb)…
GetChunks(      GetChunks          Method System.Text.StringBuilder+ChunkEnumerator GetChunks()
GetHashCode(    GetHashCode        Method int GetHashCode()
GetObjectData(  GetObjectData      Method void ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Run…
GetType(        GetType            Method type GetType()
Insert(         Insert             Method System.Text.StringBuilder Insert(int index, ulong value)…
Remove(         Remove             Method System.Text.StringBuilder Remove(int startIndex, int length)
Replace(        Replace            Method System.Text.StringBuilder Replace(string oldValue, string newValue)…
ToString(       ToString           Method string ToString()…

Actual behavior

CompletionText ListItemText  ResultType ToolTip
-------------- ------------  ---------- -------
Count          Count           Property int Count { get; }
IsReadOnly     IsReadOnly      Property bool IsReadOnly { get; }
Add(           Add               Method void ICollection[StringBuilder].Add(System.Text.StringBuilder item)
Clear(         Clear             Method void ICollection[StringBuilder].Clear()
Contains(      Contains          Method bool ICollection[StringBuilder].Contains(System.Text.StringBuilder item)
CopyTo(        CopyTo            Method void ICollection[StringBuilder].CopyTo(System.Text.StringBuilder[] array, int arrayIndex)
ForEach(       ForEach           Method ForEach(expression [, arguments...])
GetEnumerator( GetEnumerator     Method System.Collections.Generic.IEnumerator[System.Text.StringBuilder] IEnumerable[StringBuilder].GetEnumerator()…
IndexOf(       IndexOf           Method int IList[StringBuilder].IndexOf(System.Text.StringBuilder item)
Insert(        Insert            Method void IList[StringBuilder].Insert(int index, System.Text.StringBuilder item)
Remove(        Remove            Method bool ICollection[StringBuilder].Remove(System.Text.StringBuilder item)
RemoveAt(      RemoveAt          Method void IList[StringBuilder].RemoveAt(int index)
Where(         Where             Method Where({ expression } [, mode [, numberToReturn]])

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.7
PSEdition                      Core
GitCommitId                    7.2.0-preview.7
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions