Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prohibit extends on public abstract classes with private abstract members. #2654

Open
AlexanderFarkas opened this issue Nov 23, 2022 · 3 comments

Comments

@AlexanderFarkas
Copy link

AlexanderFarkas commented Nov 23, 2022

This is valid:

abstract class A {
  void _performImpl();

  void perform() {
    ...
    _performImpl();
    ...
  }
}

While extending this class from other file is always invalid.

@srawlins
Copy link
Member

One note: Extending A from within the library where A is declared can be valid.

@lrhn
Copy link
Member

lrhn commented Nov 23, 2022

The issues with library private members in public interfaces is known. We have no current plans to change that.

This is a particularly useless case, where it might be reasonable to warn the user that the class can be implemented.
I'd recommend not making the class public, rather than introduce rules preventing you from extending the class.

We hope that adding the ability to prevent implementation or extension of classes explicitly (#2242) will allow you to disallow it in the cases where you want to, without the compiler having to figure out whether a use is safe or not.

@AlexanderFarkas
Copy link
Author

AlexanderFarkas commented Nov 24, 2022

When you introduceclosed modifier for classes, lint rule no_non_closed_public_abstract_classes_with_private_abstract_members will be awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants