mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
ensure no inference from not inferred var (IDEA-193828)
This commit is contained in:
@@ -259,7 +259,8 @@ public class PsiTypesUtil {
|
||||
}
|
||||
else if (parent instanceof PsiAssignmentExpression) {
|
||||
if (PsiUtil.checkSameExpression(element, ((PsiAssignmentExpression)parent).getRExpression())) {
|
||||
return ((PsiAssignmentExpression)parent).getLExpression().getType();
|
||||
PsiType type = ((PsiAssignmentExpression)parent).getLExpression().getType();
|
||||
return !PsiType.NULL.equals(type) ? type : null;
|
||||
}
|
||||
}
|
||||
else if (parent instanceof PsiReturnStatement) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
public void testApplicabilityCheckFailsExpressionTypeCheckPasses() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNotInferredVarShouldNotBeUsedForInferenceJava10() { doTest(); }
|
||||
public void testTopLevelParentNoParameters() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user