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

OrderedATNConfigSet has bad override of configLookup field #3992

Open
jakemac53 opened this issue Nov 28, 2022 · 1 comment
Open

OrderedATNConfigSet has bad override of configLookup field #3992

jakemac53 opened this issue Nov 28, 2022 · 1 comment

Comments

@jakemac53
Copy link

jakemac53 commented Nov 28, 2022

See

final configLookup = <ATNConfig>{};

In general, overriding fields is a bad idea in Dart. Both fields exist, but the one on the super class is only accessible through an explicit super.<field> invocation.

In particular in this case, it is much worse since the subclass declares the field as final, it only overrides the getter, and not the setter. So there is a setter still, which assigns to the base class field, which can never be read (except through a super. invocation in the subclass).

In this case, the subclass does try to set the configLookup field, which has no effect, because that field is never read.

@jakemac53
Copy link
Author

Note that this causes a failure in DDC when null safety asserts are enabled, dart-lang/sdk#50569. That is technically a compiler bug, but it highlighted this pattern which is almost certainly not doing what was intended.

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

1 participant