D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16531 - Protected members not accessible in delegate bodies
Summary: Protected members not accessible in delegate bodies
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2016-09-23 19:25 UTC by John Chapman
Modified: 2020-03-02 16:48 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description John Chapman 2016-09-23 19:25:32 UTC
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.
Comment 1 John Chapman 2016-09-23 19:33:53 UTC
Forgot crucial detail that the error appears when Label is defined in a separate module from Control.
Comment 2 Mathias LANG 2020-03-02 16:48:35 UTC
Works now, probably since the removal of the access code a few releases ago.