If I try to call the protected method of a superclass from inside the body of a delegate, the compiler won't allow it.

void layoutTransaction(Control c, void delegate() action) {
  // do stuff
  action();
  // do more stuff
}

class Control {
  protected void onTextChanged() {}
}

class Label : Control {
  protected override void onTextChanged() {
    layoutTransaction(this, {
      super.onTextChanged(); // <--- Error here
      changeSize();
    });
  }
  private void changeSize() {}
}

Output: class Control member onTextChanged is not accessible.

How is it possible that "onTextChanged" isn't accessible but the private method "changeSize" *is*?

Reply via email to