Repository: dotnet/roslyn
File: src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol_Bases.cs (C#)

Code before:
            }

            CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = new CompoundUseSiteInfo<AssemblySymbol>(diagnostics, ContainingAssembly);

            if (declaration.Kind is DeclarationKind.Record or DeclarationKind.RecordStruct)
            {
                var type = DeclaringCompilation.GetWellKnownType(WellKnownType.System_IEquatable_T).Construct(this);
                if (baseInterfaces.IndexOf(type, SymbolEqualityComparer.AllIgnoreOptions) < 0)
                {
                    baseInterfaces.Add(type);
                    type.AddUseSiteInfo(ref useSiteInfo);
                }
            }

            if ((object)baseType != null)
            {
                Debug.Assert(baseTypeLocation != null);
                if (baseType.IsStatic)
                {
                    // '{1}': cannot derive from static class '{0}'
                    diagnostics.Add(ErrorCode.ERR_StaticBaseClass, baseTypeLocation, baseType, this);
                }

                if (baseType.FindTypeLessVisibleThan(this, ref useSiteInfo) is { } lessVisibleType)
                {
                    if (Equals(baseType, lessVisibleType, TypeCompareKind.ConsiderEverything))
                    {
                        // Inconsistent accessibility: base class '{1}' is less accessible than class '{0}'
                        diagnostics.Add(ErrorCode.ERR_BadVisBaseClass, baseTypeLocation, this, lessVisibleType);
                    }
                    else
                    {
                        // Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
                        var lessVisibleTypeLocation = lessVisibleType.GetFirstLocation();
                        diagnostics.Add(ErrorCode.ERR_BadVisBaseType, baseTypeLocation, this, lessVisibleType);
                    }
                }

                if (baseType.HasFileLocalTypes() && !this.HasFileLocalTypes())
                {
                    diagnostics.Add(ErrorCode.ERR_FileTypeBase, baseTypeLocation, baseType, this);
                }
            }

            var baseInterfacesRO = baseInterfaces.ToImmutableAndFree();
            if (DeclaredAccessibility != Accessibility.Private && IsInterface)
            {
                foreach (var i in baseInterfacesRO)
                {
                    if (!i.IsAtLeastAsVisibleAs(this, ref useSiteInfo))
                    {

Review comment (suggestion):
```suggestion
                    if (ReferenceEquals(baseType, lessVisibleType))
```

Code after:
            }

            CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = new CompoundUseSiteInfo<AssemblySymbol>(diagnostics, ContainingAssembly);

            if (declaration.Kind is DeclarationKind.Record or DeclarationKind.RecordStruct)
            {
                var type = DeclaringCompilation.GetWellKnownType(WellKnownType.System_IEquatable_T).Construct(this);
                if (baseInterfaces.IndexOf(type, SymbolEqualityComparer.AllIgnoreOptions) < 0)
                {
                    baseInterfaces.Add(type);
                    type.AddUseSiteInfo(ref useSiteInfo);
                }
            }

            if ((object)baseType != null)
            {
                Debug.Assert(baseTypeLocation != null);
                if (baseType.IsStatic)
                {
                    // '{1}': cannot derive from static class '{0}'
                    diagnostics.Add(ErrorCode.ERR_StaticBaseClass, baseTypeLocation, baseType, this);
                }

                if (baseType.FindTypeLessVisibleThan(this, ref useSiteInfo) is { } lessVisibleType)
                {
                    if (ReferenceEquals(baseType, lessVisibleType))
                    {
                        // Inconsistent accessibility: base class '{1}' is less accessible than class '{0}'
                        diagnostics.Add(ErrorCode.ERR_BadVisBaseClass, baseTypeLocation, this, lessVisibleType);
                    }
                    else
                    {
                        // Inconsistent accessibility: type '{1}' is less accessible than class '{0}'
                        var lessVisibleTypeLocation = lessVisibleType.GetFirstLocation();
                        diagnostics.Add(ErrorCode.ERR_BadVisBaseType, baseTypeLocation, this, lessVisibleType);
                    }
                }

                if (baseType.HasFileLocalTypes() && !this.HasFileLocalTypes())
                {
                    diagnostics.Add(ErrorCode.ERR_FileTypeBase, baseTypeLocation, baseType, this);
                }
            }

            var baseInterfacesRO = baseInterfaces.ToImmutableAndFree();
            if (DeclaredAccessibility != Accessibility.Private && IsInterface)
            {
                foreach (var i in baseInterfacesRO)
                {
                    if (!i.IsAtLeastAsVisibleAs(this, ref useSiteInfo))
                    {