Skip to content

Kotlin: Mutable collections have methods to change them and not notify the protocol #338

@ForNeVeR

Description

@ForNeVeR

Currently, there are some methods in mutable Rd collections (all implementors of IMutableViewableMap, IMutableViewableList, and IMutableViewableSet) that will modify the collections but won't trigger the accompanying action (such as taking a cookie, writing the value to the protocol etc.).

This is caused by two issues:

  1. Interface delegation (i.e. IMutableViewableMap<K, V> by map clause in the RdMap's inheritance list) will just call all the methods from the base object without wrapping them, if they aren't overridden in the implementing class. So, this delegation should be removed.
  2. Mutable collections in Kotlin expose members that allow indirect mutation of the collection: say, Map::entries: MutableCollection<Map.Entry>, or iterator: MutableIterator, or even MutableMap.MutableEntry.

Particularly problematic methods in this regard are variations of MutableList::addAll and MutableMap::putAll (soon to be fixed), but I'm not sure about a systematic solution, yet.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions