Unexpected error CS0146: "Circular base class dependency involving 'A.B' and 'A.B'" in using static directive
#369 opened on Feb 10, 2015
Description
using static A.B.B;
class A
{
public class B : A { }
}
ACTUAL: SourceCode.cs(1,18): error CS0146: Circular base class dependency involving 'A.B' and 'A.B'
EXPECTED: No errors
The problem seems to be in the Microsoft.CodeAnalysis.CSharp.InContainerBinder.LookupSymbolsInSingleBinder method (%Roslyn%\src\Compilers\CSharp\Portable\Binder\InContainerBinder.cs, around line 151).
It looks like there is no inherent circularity there, but it arises because of the particular order of method calls in our implementation. We unconditionally call GetImports first to completely bind all using directives, but this is not actually necessary if we find the declaration of the required symbol directly in the corresponding namespace declaration, we only need to check the names of aliases introduced in using alias directives for potential conflicts (we do not even need to bind the symbols they refer to), and we should not care at all about using namespace or using static directives in this case.
[Migrated from TFS DevDiv 1108103]