Inspectopedia
 
2024.3

Call of Java mutator method on immutable Kotlin collection

Warning
New
Last modified: 03 December 2024

Reports Java mutator methods calls (like fill, reverse, shuffle, sort) on an immutable Kotlin collection.

This can lead to UnsupportedOperationException at runtime.

Example:

To fix the problem make the list mutable.