ready to nulls (EA-52470 - IAE: TypeCompatibilityConstraint.<init>)

This commit is contained in:
anna
2013-11-28 20:21:40 +01:00
parent bb9f2c7014
commit d88f344fd6
3 changed files with 31 additions and 0 deletions
@@ -18,6 +18,8 @@ package com.intellij.psi.impl.source.resolve.graphInference;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.ParameterTypeInferencePolicy;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -86,6 +88,14 @@ public class PsiGraphInferenceHelper implements PsiInferenceHelper {
boolean isContraVariantPosition,
LanguageLevel languageLevel) {
if (arg == PsiType.VOID || param == PsiType.VOID) return PsiType.NULL;
if (param instanceof PsiArrayType && arg instanceof PsiArrayType) {
return getSubstitutionForTypeParameter(typeParam, ((PsiArrayType)param).getComponentType(), ((PsiArrayType)arg).getComponentType(), isContraVariantPosition, languageLevel);
}
if (!(param instanceof PsiClassType)) return PsiType.NULL;
if (arg == null) {
return PsiType.NULL;
}
final PsiType[] leftTypes;
final PsiType[] rightTypes;
if (isContraVariantPosition) {
@@ -0,0 +1,5 @@
class A<T extends String> {
{
A a = new A<<caret>>();
}
}
@@ -17,6 +17,9 @@ package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.impl.source.resolve.PsiResolveHelperImpl;
import com.intellij.psi.impl.source.resolve.graphInference.PsiGraphInferenceHelper;
import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.annotations.NotNull;
@@ -70,6 +73,19 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
doTest();
}
public void testInferFromRawType() throws Exception {
final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
try {
configureByFile("/" + getTestName(false) + ".java");
assertNotNull(myItems);
assertTrue(myItems.length == 0);
}
finally {
helper.setTestHelper(null);
}
}
private void doTest() {
configureByFile("/" + getTestName(false) + ".java");
assertNotNull(myItems);