May 13, 2023
https://issues.dlang.org/show_bug.cgi?id=23921

          Issue ID: 23921
           Summary: The compiler is too pessimistic on how a double
                    context might be required
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: b2.temp@gmx.com

The following code

```
class A
{
    void f()
    {
        class B : A
        {
            override void f()
            {
                class C : B
                {
                    override void f()
                    {
                        class D : C
                        {
                            override void f()
                            {
                            }
                        }

                        D abcd;
                    }
                }

                C abc;
            }
        }

        B ab;
    }
}
```

is rejected with

> A.f.B.f.C` is nested within `f`, but super class `B` is nested within `f`

But the very similar

```
class A
{
    void f()
    {
        static class B : A
        {
            override void f()
            {
                static class C : B
                {
                    override void f()
                    {
                        static class D : C
                        {
                            override void f()
                            {
                            }
                        }

                        D abcd;
                    }
                }

                C abc;
            }
        }

        B ab;
    }
}
```

is accepted.

--