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

entry.list in LinkedList #50937

Open
Run10Break1 opened this issue Jan 7, 2023 · 1 comment
Open

entry.list in LinkedList #50937

Run10Break1 opened this issue Jan 7, 2023 · 1 comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-collection type-enhancement A request for a change that isn't a bug

Comments

@Run10Break1
Copy link

LinkedList uses entry.list for accessing LinkedList containing it in functions like _insertBefore() or contains().

But It makes overriding get list in LinkedListEntry impossible. If you override get list throws an exception, just calling add() also throws the exception.

I found this problem when I make a subclass of LinkedListEntry prohibiting access to the list for logic safety.

So, I carefully suggest changing entry.list to entry._list like the other parts in remove() or _unlink().

thanks.

@lrhn
Copy link
Member

lrhn commented Jan 7, 2023

The LinkedList class is not amazing design. I'd recommend just writing your own from scratch, if the one in dart:collection doesn't do what you want.
Making a part of the API throw is not something it's build to support.

I'd like to say that the reason LinkedList uses entry.list is that it allows custom implementations of LinkedListEntry, which might not have a _list getter at all. Using a private getter like ._list on anything except this is unsafe, and something which has bitten us in other places.
However, the class violates that design in lots of places, so one more or less won't change anything.

@lrhn lrhn added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-collection type-enhancement A request for a change that isn't a bug labels Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-collection type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants