@@ -2564,11 +2564,19 @@ foreach ($parent in $this.GetLineage()) {
2564
2564
$y = 2
2565
2565
$x + $y
2566
2566
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetVariableType()
2567
+ # Should -Be ([int])
2567
2568
.EXAMPLE
2568
2569
{
2569
2570
$x = Get-Process
2570
2571
$x + $y
2571
2572
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetVariableType()
2573
+ # Should -Be ([Diagnostics.Process])
2574
+ .EXAMPLE
2575
+ {
2576
+ $x = [type].name
2577
+ $x
2578
+ }.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.GetVariableType()
2579
+
2572
2580
#>
2573
2581
if ($this.VariablePath.userPath -eq 'psBoundParmeters') {
2574
2582
return [Management.Automation.PSBoundParametersDictionary]
@@ -2610,7 +2618,7 @@ $isMultiAssignment =$closestAssignment.Left -is [Management.Automation.Language.
2610
2618
2611
2619
# If the left side is not multiple assignment, but the right side is an array
2612
2620
if (-not $isMultiAssignment -and
2613
- $closestAssignment.Right.Expression -is [Management.Automation.ArrayExpressionAst]) {
2621
+ $closestAssignment.Right.Expression -is [Management.Automation.Language. ArrayExpressionAst]) {
2614
2622
# then the object is an array.
2615
2623
return [Object[]]
2616
2624
}
@@ -2634,7 +2642,24 @@ if ($closestAssignment.Right.Expression -is [Management.Automation.Language.Conv
2634
2642
}
2635
2643
}
2636
2644
2637
-
2645
+ if ($closestAssignment.Right.Expression -is [Management.Automation.Language.MemberExpressionAst]) {
2646
+ $invokeMemberExpr = $closestAssignment.Right.Expression
2647
+ $memberName = $invokeMemberExpr.Member.ToString()
2648
+ if ($invokeMemberExpr.Expression.TypeName) {
2649
+ $invokeType = $invokeMemberExpr.Expression.TypeName.GetReflectionType()
2650
+ if ($invokeType) {
2651
+ $potentialTypes = @(
2652
+ foreach ($invokeableMember in $invokeType.GetMember($memberName, "Public, IgnoreCase,$(if ($invokeMemberExpr.Static) { 'Static'} else { 'Instance'})")) {
2653
+ if ($invokeableMember.PropertyType) {
2654
+ $invokeableMember.PropertyType
2655
+ } elseif ($invokeableMember.ReturnType) {
2656
+ $invokeableMember.ReturnType
2657
+ }
2658
+ })
2659
+ return $potentialTypes | Select-Object -Unique
2660
+ }
2661
+ }
2662
+ }
2638
2663
2639
2664
2640
2665
# The right side could be a pipeline
0 commit comments