ensure no inference from not inferred var (IDEA-193828)

This commit is contained in:
Anna Kozlova
2018-06-13 20:56:56 +03:00
parent 3dcd60cbb5
commit dc43909e2c
3 changed files with 20 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
class MyTest {
public List<Integer> someMethod() {
<error descr="Cannot infer type: 'var' on variable without initializer">var</error> listOfInteger;
Integer[] arrayOfInteger = {2, 4, 8};
<error descr="Incompatible types. Found: 'java.util.ArrayList<java.lang.Integer>', required: 'null'">listOfInteger = Arrays.stream(arrayOfInteger)
.filter(number -> number >= 4)
.collect(Collectors.toCollection(ArrayList::new))</error>;
return listOfInteger;
}
}