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

Collections library: supporing immutable part of interfaces. #719

Closed
DartBot opened this issue Dec 7, 2011 · 2 comments
Closed

Collections library: supporing immutable part of interfaces. #719

DartBot opened this issue Dec 7, 2011 · 2 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.

Comments

@DartBot
Copy link

DartBot commented Dec 7, 2011

This issue was originally filed by karl.k...@gmail.com


In Java, the interfaces in the collections library allow that implementors only implement the read-only part of the interface throwing UnsupportedOperationException when calling the mutating part.

The Dart interfaces don't explicitly say this. I believe they should, as it allows implementing immutable collection types that implement the Dart collections interfaces.

For example, one might change

interface List<E> extends Collection<E> factory ListFactory {
//...

  /**
   * Sets the entry at the given [index] in the list to [value].
   * Throws an [IndexOutOfRangeException] if [index] is out of bounds.
   */
  void operator []=(int index, E value);
//...
}

to

interface List<E> extends Collection<E> factory ListFactory {
//...

  /**
   * Sets the entry at the given [index] in the list to [value].
   * Throws an [IndexOutOfRangeException] if [index] is out of bounds.
   * Throws an [UnsupportedOperationException] if the list is immutable.
   */
  void operator []=(int index, E value);
//...
}

etc.

@DartBot
Copy link
Author

DartBot commented Dec 8, 2011

This comment was originally written by drfibonacci@google.com


Added Area-Library, Triaged labels.

@lrhn
Copy link
Member

lrhn commented Jun 4, 2013

I believe this has been documented in the base collection classes now.
An unmodifiable List will throw UnsupportedError for mutating methods.


Added Fixed label.

@DartBot DartBot added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Jun 4, 2013
copybara-service bot pushed a commit that referenced this issue Nov 17, 2023
Revisions updated by `dart tools/rev_sdk_deps.dart`.

lints (https://github.com/dart-lang/lints/compare/f58fd77..3810f8b):
  3810f8b  2023-11-14  Devon Carew  add a section on upgrading to the latest lint set to the readme (#171)

mockito (https://github.com/dart-lang/mockito/compare/fcb9779..fb8a2b5):
  fb8a2b5  2023-11-16  Kevin Moore  No public description
  2f41028  2023-11-16  Copybara-Service  Merge pull request #719 from dart-lang:latest_lints
  8b5036b  2023-11-16  Kevin Moore  release later
  ecc62f6  2023-11-16  Kevin Moore  Update to the latest lints, require Dart 3.1, prepare release
  dc3eb65  2023-11-15  Ilya Yanok  Generate valid functions with optional non-nullable arguments

sse (https://github.com/dart-lang/sse/compare/8ddb95f..0f6ca11):
  0f6ca11  2023-11-15  Kevin Moore  Require Dart 3.2, use pkg:web (#92)

tools (https://github.com/dart-lang/tools/compare/2e36b8d..4649307):
  4649307  2023-11-15  Elias Yishak  Add terminal info to flutter command event (#204)
  4e75286  2023-11-13  Devon Carew  remove duplicate settings from analysis_options files (#201)

Change-Id: Ie0d8c1897e22ca04563bdc0320cf7485f6e63f7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336825
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This issue was closed.
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.
Projects
None yet
Development

No branches or pull requests

2 participants