null types (IDEA-146740)

This commit is contained in:
Anna Kozlova
2015-10-26 13:50:02 +01:00
parent 116f2b129e
commit 47c3c2bbc1
4 changed files with 25 additions and 2 deletions
@@ -72,6 +72,11 @@ public class InferenceVariable extends LightTypeParameter {
list = new ArrayList<PsiType>();
myBounds.put(inferenceBound, list);
}
if (classType == null) {
classType = PsiType.NULL;
}
final int idx = list.indexOf(classType);
if (idx < 0) {
list.add(classType);
@@ -72,8 +72,8 @@ public class TypeEqualityConstraint implements ConstraintFormula {
}
if (session.isProperType(myT) && session.isProperType(myS)) {
if (myT == null) return myS == null || myS.equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
if (myS == null) return true;
if (myT == null || myT == PsiType.NULL) return myS == null || myS == PsiType.NULL || myS.equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
if (myS == null || myS == PsiType.NULL) return true;
return Comparing.equal(myT, myS);
}
InferenceVariable inferenceVariable = session.getInferenceVariable(myS);
@@ -0,0 +1,14 @@
import java.util.List;
import java.util.Set;
class Test {
void foo(List<Set<String>> dictSeqs) {
final Dict<String> dict = new Dict<>(dictSeqs.toArray(new Set[dictSeqs.size()]));
final Dict<String> dict1 = new Dict<String>(dictSeqs.toArray(new Set[dictSeqs.size()]));
}
static class Dict<K extends Comparable<K>> {
public Dict(final Set<K>... sex) {}
}
}
@@ -55,6 +55,10 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testNullTypesInDiamondsInference() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
}