mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
IDEA-229683 Replacement IntStream.range.mapToObj with Arrays.stream is wrong when array elements are written.
GitOrigin-RevId: c386abf6f7716ec75b49ca5e6b0a5676c29b1744
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9fb8d24627
commit
3718ed889f
@@ -1220,8 +1220,8 @@ public class SimplifyStreamApiCallChainsInspection extends AbstractBaseJavaLocal
|
||||
if (body == null) return null;
|
||||
Collection<PsiReference> refs = ReferencesSearch.search(indexParameter, new LocalSearchScope(body)).findAll();
|
||||
if (!refs.isEmpty() &&
|
||||
refs.stream()
|
||||
.allMatch(ref -> limitedContainer.myContainer.extractGetExpressionFromIndex(tryCast(ref, PsiExpression.class)) != null)) {
|
||||
refs.stream().map(ref -> limitedContainer.myContainer.extractGetExpressionFromIndex(tryCast(ref, PsiExpression.class)))
|
||||
.allMatch(expression -> expression != null && !PsiUtil.isAccessedForWriting(expression))) {
|
||||
return limitedContainer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// "Replace IntStream.range().mapToObj() with Arrays.stream(strs)" "false"
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
void test() {
|
||||
String [] strs = new String[239];
|
||||
List<String> collect = IntStream.range(0, strs.length).
|
||||
<Runnable><caret>mapToObj(idx -> () -> strs[idx] = strs[idx].toUpperCase()).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user