Skip to content

UnmodifiableListView object, when set to a List object, does not throw an analysis error #30519

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

Closed
maryx opened this issue Aug 22, 2017 · 1 comment
Labels
closed-duplicate Closed in favor of an existing report

Comments

@maryx
Copy link

maryx commented Aug 22, 2017

List is not a subclass of UnmodifiableListView, so we shouldn't be able to set a variable defined with type UnmodifiableListView to a List. When we try to set an UnmodifiableListView to a List, the dart analyzer should throw an error or warning.
E.g. this code is currently allowed and builds fine:

import 'dart:collection';

List<String> _list;
UnmodifiableListView<String> get publicList => _list; // should throw error; currently doesn't

The above should instead be written as:

import 'dart:collection';

List<String> _list;
List<String> get publicList => new UnmodifiableListView<String>(_list);
@matanlurey matanlurey added the closed-duplicate Closed in favor of an existing report label Aug 22, 2017
@matanlurey
Copy link
Contributor

I believe this would be covered by implicit-casts:
https://www.dartlang.org/guides/language/analysis-options#specifying-strong-mode

Seems like a duplicate of #30392.

See also: #30397.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

2 participants