Files
openide/plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/UselessCallOnCollection.html
Ilya Kirillov 3386f8f5a9 [kotlin] move inspection descriptions to separate module to reuse in K2
GitOrigin-RevId: e9d7382f4d640e27b1958d1bf2d4c3e639915137
2022-07-13 09:59:31 +00:00

17 lines
754 B
HTML

<html>
<body>
Reports <code>filter…</code> calls from the standard library on already filtered collections.
<p>Several functions from the standard library such as <code>filterNotNull()</code> or <code>filterIsInstance</code>
have sense only when they are called on receivers that have types distinct from the resulting one. Otherwise,
such calls can be omitted as the result will be the same.</p>
<p><b>Remove redundant call</b> quick-fix can be used to amend the code automatically.</p>
<p>Example:</p>
<pre><code>
fun test(list: List&lt;String&gt;) {
val x = list.filterNotNull() // quick-fix simplifies to 'list'
val y = list.filterIsInstance&lt;String&gt;() // quick-fix simplifies to 'list'
}
</code></pre>
</body>
</html>