mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-dfa] toMap collector: Flush Map size on update
GitOrigin-RevId: def13d95f991e7601682c03f5a2029ed332dc757
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9bebeeaeec
commit
4dfb7b9999
+1
-1
@@ -697,7 +697,7 @@ public class StreamChainInliner implements CallInliner {
|
||||
.end();
|
||||
}
|
||||
// Actual addition of Map element is unnecessary for current analysis
|
||||
builder.pop();
|
||||
builder.flush(SpecialField.COLLECTION_SIZE.createValue(builder.getFactory(), myResult)).pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import java.util.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
class Test {
|
||||
// IDEA-246544
|
||||
public static void main(String[] args) {
|
||||
List<Float> decimals = new ArrayList<>(Arrays.asList(1.2f, 4.4f, 2.7f, 2.5f));
|
||||
HashMap<Integer, List<Float>> decimalsGroupedByTheirIntegerParts = decimals.stream().collect(Collectors.toMap(
|
||||
Float::intValue,
|
||||
Collections::singletonList,
|
||||
(subgroup1, subgroup2) -> Stream.concat(subgroup1.stream(), subgroup2.stream()).collect(Collectors.toList()),
|
||||
() -> new HashMap<>()
|
||||
));
|
||||
if (decimalsGroupedByTheirIntegerParts.isEmpty()) {}
|
||||
|
||||
decimals.clear();
|
||||
HashMap<Integer, List<Float>> decimalsGroupedByTheirIntegerParts2 = decimals.stream().collect(Collectors.toMap(
|
||||
Float::intValue,
|
||||
Collections::singletonList,
|
||||
(subgroup1, subgroup2) -> Stream.concat(subgroup1.stream(), subgroup2.stream()).collect(Collectors.toList()),
|
||||
() -> new HashMap<>()
|
||||
));
|
||||
if (<warning descr="Condition 'decimalsGroupedByTheirIntegerParts2.isEmpty()' is always 'true'">decimalsGroupedByTheirIntegerParts2.isEmpty()</warning>) {}
|
||||
}
|
||||
}
|
||||
@@ -187,6 +187,7 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
|
||||
public void testStreamInlining() { doTest(); }
|
||||
public void testStreamCollectorInlining() { doTest(); }
|
||||
public void testStreamToMapInlining() { doTest(); }
|
||||
public void testStreamToMapInlining2() { doTest(); }
|
||||
public void testStreamToCollectionInlining() { doTest(); }
|
||||
public void testStreamComparatorInlining() { doTest(); }
|
||||
public void testStreamKnownSource() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user