Bug 16531 – Protected members not accessible in delegate bodies

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-09-23T19:25:32Z
Last change time
2020-03-02T16:48:35Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
John Chapman

Comments

Comment #0 by johnch_atms — 2016-09-23T19:25:32Z
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 by johnch_atms — 2016-09-23T19:33:53Z
Forgot crucial detail that the error appears when Label is defined in a separate module from Control.
Comment #2 by pro.mathias.lang — 2020-03-02T16:48:35Z
Works now, probably since the removal of the access code a few releases ago.