-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Non-overridable members #27502
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
Comments
Non-overrideable members is completely contrary to the Dart object model. A limitation of one implementation should not poison the language. |
Status update: |
FYI, DDC support for this should be implemented, and I left support for Analyzer to easily re-add if needed. The "isVirtual" getter is hard coded to return true now, but it would be easy to have it return false if EDIT: although note the Analyzer has a problem with checking ClassTypeAlias syntax: class A { int x = 0; }
class M { int x = 1; }
class C = A with M; |
In other words, LMK if y'all want to add Analyzer support for |
DDC now allows overriding fields. |
Dart specifies that all members, including fields, can be overridden by subclasses or implemented by interfaces.
dev_compiler does not support overriding fields because it forces fields to be compiled to larger, slower JS. Strong mode in turn therefore makes overriding a field a static error.
When investigating instances of that error, Leaf discovered almost every single case where a field was being overridden was in fact bad code. In most cases, the intent for the "field" was actually to declare an abstract getter/setter.
Flutter (among others) have requested to be able to declare that some members cannot be overridden.
The language has committed to at least declaring fields that can and cannot be overridden or implemented. We have not yet decided:
This bug is to decide and implement those.
See also: #24928, #27385, #27452, #27372.
The text was updated successfully, but these errors were encountered: