Hello,

I came across this unexpected error in the first example, so I tested similar scenarios, but couldn't make any sense of it.

Thanks, Eberhard.


class A {
   void foo() {}

   static class B {
      private A a;
      alias a this;
                
      void bar() {
         this.foo(); // works fine
foo(); // Error: this for `foo` needs to be type `A` not type `A.B`
      }
   }
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class A {
   void foo() {}
}

class B {
   void foo() {}
        
   static class C {
      private A a;
      alias a this;
                
      void bar() {
         this.foo(); // works fine
foo(); // Error: this for `foo` needs to be type `B` not type `B.C`
      }
   }
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class A {
   void foo() {}
}

class B {
   // no foo
        
   static class C {
      private A a;
      alias a this;
                
      void bar() {
         this.foo(); // works fine
         foo();      // works fine
      }
   }
}

Reply via email to