www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16531] New: Protected members not accessible in delegate bodies

https://issues.dlang.org/show_bug.cgi?id=16531

          Issue ID: 16531
           Summary: Protected members not accessible in delegate bodies
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johnch_atms hotmail.com

DMD reports an error when trying to call the protected method of a superclass
from inside the body of a delegate. Code to repro:

void layoutTransaction(void delegate() action) {
  action();
}

class Control {
  protected void onTextChanged() {}
}

class Label : Control {
  protected override void onTextChanged() {
    layoutTransaction({
      super.onTextChanged();
    });
  }
}

Output: class Control member onTextChanged is not accessible.

I think protected methods should be allowed to be called in this way. Note that
private methods do seem to be accessible.

--
Sep 23 2016