Repository: dotnet/roslyn
File: src/Compilers/CSharp/Portable/Binder/LookupResult.cs (C#)

Code before:
                    {
                        _symbolList.Add(result.Symbol);
                    }
                }
                // else: existing result is preferred (generic over non-generic), keep it
            }
            else if ((object)result.Symbol != null)
            {
                // Same goodness. Include all symbols
                _symbolList.Add(result.Symbol);
            }
        }

        private static bool PreferGenericOverNonGeneric(Symbol currentSymbol, Symbol newSymbol)
        {
            // Prefer a generic type (arity > 0) over a non-generic type (arity == 0)
            // when both are NamedTypeSymbols with WrongArity
            if (currentSymbol is NamedTypeSymbol currentType && newSymbol is NamedTypeSymbol newType)
            {
                // Prefer the one with arity > 0 (generic) over arity == 0 (non-generic)
                if (currentType.Arity == 0 && newType.Arity > 0)
                {
                    return true; // prefer new symbol (generic) over current (non-generic)
                }
            }
            return false;
        }

        // global pool
        //TODO: consider if global pool is ok.
        private static readonly ObjectPool<LookupResult> s_poolInstance = CreatePool();

        // if someone needs to create a pool
        internal static ObjectPool<LookupResult> CreatePool()
        {
            ObjectPool<LookupResult> pool = null;
            pool = new ObjectPool<LookupResult>(() => new LookupResult(pool), 128); // we rarely need more than 10
            return pool;
        }

        internal static LookupResult GetInstance()
        {
            var instance = s_poolInstance.Allocate();
            Debug.Assert(instance.IsClear);
            return instance;
        }

        internal void Free()
        {
            this.Clear();
            if (_pool != null)

Review comment (suggestion):
```suggestion
            return currentSymbol is NamedTypeSymbol { Arity: 0 } && newSymbol is NamedTypeSymbol { Arity: > 0 };
``` #Closed

Code after:
                }

                if (isNonGenericVersusGeneric(this.SingleSymbolOrDefault, result.Symbol))
                {
                    // Current result is non generic, but incoming is generic.  It's strictly the better symbol to be
                    // referring to when generics are provided, but arity is wrong.
                    this.SetFrom(result);
                    return;
                }

                // Neither is preferred, fall through and include all symbols.
            }

            // Same goodness. Include all symbols
            _symbolList.AddIfNotNull(result.Symbol);

            static bool isNonGenericVersusGeneric(Symbol firstSymbol, Symbol secondSymbol)
                => firstSymbol.GetArity() == 0 && secondSymbol.GetArity() > 0;
        }

        // global pool
        //TODO: consider if global pool is ok.
        private static readonly ObjectPool<LookupResult> s_poolInstance = CreatePool();

        // if someone needs to create a pool
        internal static ObjectPool<LookupResult> CreatePool()
        {
            ObjectPool<LookupResult> pool = null;
            pool = new ObjectPool<LookupResult>(() => new LookupResult(pool), 128); // we rarely need more than 10
            return pool;
        }

        internal static LookupResult GetInstance()
        {
            var instance = s_poolInstance.Allocate();
            Debug.Assert(instance.IsClear);
            return instance;
        }

        internal void Free()
        {
            this.Clear();
            if (_pool != null)
            {
                _pool.Free(this);
            }
        }
    }
}