Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/CommandCompletion/CompletionAnalysis.cs (C#)

Code before:
                }
            }

            return typeConstraint != null || setConstraint != null;
        }

        private static List<CompletionResult> CompletePropertyAssignment(MemberExpressionAst memberExpression, CompletionContext context)
        {
            if (SafeExprEvaluator.TrySafeEval(memberExpression, context.ExecutionContext, out var evalValue))
            {
                if (evalValue is not null)
                {
                    Type type = evalValue.GetType();
                    if (type.IsEnum)
                    {
                        return GetResultForEnum(type, context);
                    }

                    return null;
                }
            }

            if (!TryGetInferredCompletionsForAssignment(memberExpression, context, out List<CompletionResult> result))
            {
                result = null;
            }

            return result;
        }

        private static bool TryGetInferredCompletionsForAssignment(Ast expression, CompletionContext context, out List<CompletionResult> result)
        {
            result = new List<CompletionResult>();
            IList<PSTypeName> inferredTypes;
            if (expression.Parent is ConvertExpressionAst convertExpression)
            {
                inferredTypes = new PSTypeName[] { new(convertExpression.Type.TypeName) };
            }
            else if (expression is MemberExpressionAst)
            {
                inferredTypes = AstTypeInference.InferTypeOf(expression);
            }
            else if (expression is VariableExpressionAst varExpression)
            {
                PSTypeName typeConstraint = CompletionCompleters.GetLastDeclaredTypeConstraint(varExpression, context.TypeInferenceContext);
                if (typeConstraint is null)
                {
                    return false;
                }

                inferredTypes = new PSTypeName[] { typeConstraint };

Review comment (suggestion):
I think if TryGetInferredCompletionsForAssignment return false we should return null in result. It is common pattern.

Code after:
                }
            }

            return typeConstraint != null || setConstraint != null;
        }

        private static List<CompletionResult> CompletePropertyAssignment(MemberExpressionAst memberExpression, CompletionContext context)
        {
            if (SafeExprEvaluator.TrySafeEval(memberExpression, context.ExecutionContext, out var evalValue))
            {
                if (evalValue is not null)
                {
                    Type type = evalValue.GetType();
                    if (type.IsEnum)
                    {
                        return GetResultForEnum(type, context);
                    }

                    return null;
                }
            }

            _ = TryGetInferredCompletionsForAssignment(memberExpression, context, out List<CompletionResult> result);
            return result;
        }

        private static bool TryGetInferredCompletionsForAssignment(Ast expression, CompletionContext context, out List<CompletionResult> result)
        {
            result = null;
            IList<PSTypeName> inferredTypes;
            if (expression.Parent is ConvertExpressionAst convertExpression)
            {
                inferredTypes = new PSTypeName[] { new(convertExpression.Type.TypeName) };
            }
            else if (expression is MemberExpressionAst)
            {
                inferredTypes = AstTypeInference.InferTypeOf(expression);
            }
            else if (expression is VariableExpressionAst varExpression)
            {
                PSTypeName typeConstraint = CompletionCompleters.GetLastDeclaredTypeConstraint(varExpression, context.TypeInferenceContext);
                if (typeConstraint is null)
                {
                    return false;
                }

                inferredTypes = new PSTypeName[] { typeConstraint };
            }
            else
            {
                return false;