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

Code before:
                    methodName = "op_Multiply";
                    break;

                case TokenKind.Divide:
                    methodName = "op_Division";
                    break;

                case TokenKind.Rem:
                    methodName = "op_Modulus";
                    break;

                case TokenKind.Shl:
                    methodName = "op_LeftShift";
                    break;

                case TokenKind.Shr:
                    methodName = "op_RightShift";
                    break;

                default:
                    return lhsTypes;
            }

            List<PSTypeName> rhsTypes = InferTypes(binaryExpressionAst.Right).ToList();
            HashSet<string> addedReturnTypes = [];
            List<PSTypeName> result = [];
            foreach (var lType in lhsTypes)
            {
                if (lType.Type is null)
                {
                    continue;
                }

                foreach (MethodInfo method in lType.Type.GetMethods(BindingFlags.Public | BindingFlags.Static))
                {
                    if (!method.Name.Equals(methodName, StringComparison.Ordinal))
                    {
                        continue;
                    }

                    if (rhsTypes.Count == 0)
                    {
                        if (addedReturnTypes.Add(method.ReturnType.FullName))
                        {
                            result.Add(new PSTypeName(method.ReturnType));
                        }

                        continue;
                    }

                    ParameterInfo[] methodParams = method.GetParameters();

Review comment (suggestion):
I'd prefer classic style.
(I'm not against the new syntax, but only if it's used everywhere. We can do this later by using the analyzer auto fix.)
```suggestion
            HashSet<string> addedReturnTypes = new HashSet<string>();
            List<PSTypeName> result = new List<PSTypeName>();
```

Code after:
                    methodName = "op_Multiply";
                    break;

                case TokenKind.Plus:
                    methodName = "op_Addition";
                    break;

                case TokenKind.Rem:
                    methodName = "op_Modulus";
                    break;

                case TokenKind.Shl:
                    methodName = "op_LeftShift";
                    break;

                case TokenKind.Shr:
                    methodName = "op_RightShift";
                    break;

                default:
                    return lhsTypes;
            }

            List<PSTypeName> rhsTypes = InferTypes(binaryExpressionAst.Right).ToList();
            HashSet<string> addedReturnTypes = new HashSet<string>();
            List<PSTypeName> result = new List<PSTypeName>();
            foreach (PSTypeName lType in lhsTypes)
            {
                if (lType.Type is null)
                {
                    continue;
                }

                foreach (MethodInfo method in lType.Type.GetMethods(BindingFlags.Public | BindingFlags.Static))
                {
                    if (!method.Name.Equals(methodName, StringComparison.Ordinal))
                    {
                        continue;
                    }

                    if (rhsTypes.Count == 0)
                    {
                        if (addedReturnTypes.Add(method.ReturnType.FullName))
                        {
                            result.Add(new PSTypeName(method.ReturnType));
                        }

                        continue;
                    }

                    ParameterInfo[] methodParams = method.GetParameters();