[Issue 16531] New: Protected members not accessible in delegate bodies

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Sep 23 12:25:32 PDT 2016


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 at puremagic.com
          Reporter: johnch_atms at 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.

--


More information about the Digitalmars-d-bugs mailing list