smart completion: detect cases when inference can infer only trivial Object bound (IDEA-153970)

This commit is contained in:
Anna.Kozlova
2016-04-26 15:32:31 +02:00
parent bfb1104420
commit ee6b6e00df
3 changed files with 3 additions and 6 deletions
@@ -373,7 +373,7 @@ public class CodeInsightUtil {
arg,
true,
PsiUtil.getLanguageLevel(context));
if (PsiType.NULL.equals(substitution) || substitution instanceof PsiWildcardType) continue;
if (PsiType.NULL.equals(substitution) || substitution != null && substitution.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || substitution instanceof PsiWildcardType) continue;
if (substitution == null) {
result.consume(createType(inheritor, facade.getElementFactory().createRawSubstitutor(inheritor), arrayDim));
return true;
@@ -117,7 +117,8 @@ public class PsiGraphInferenceHelper implements PsiInferenceHelper {
leftTypes = new PsiType[] {arg};
rightTypes = new PsiType[]{param};
}
final PsiTypeParameter[] typeParams = new PsiTypeParameter[] {typeParam};
final PsiTypeParameterListOwner owner = typeParam.getOwner();
final PsiTypeParameter[] typeParams = owner != null ? owner.getTypeParameters() : new PsiTypeParameter[] {typeParam};
final InferenceSession inferenceSession = new InferenceSession(typeParams, leftTypes, rightTypes, PsiSubstitutor.EMPTY, myManager, null);
if (inferenceSession.isProperType(inferenceSession.substituteWithInferenceVariables(param)) &&
inferenceSession.isProperType(inferenceSession.substituteWithInferenceVariables(arg))) {
@@ -17,12 +17,9 @@ package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.idea.Bombed;
import com.intellij.testFramework.LightProjectDescriptor;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
public class SmartType18CompletionTest extends LightFixtureCompletionTestCase {
@Override
protected String getBasePath() {
@@ -186,7 +183,6 @@ public void testConvertToObjectStream() {
checkResultByFile("/" + getTestName(false) + "-out.java");
}
@Bombed(user = "anna/peter", month = Calendar.MAY, day = 4)
public void testOnlyCompatibleTypes() {
configureByTestName();
assertOrderedEquals(myFixture.getLookupElementStrings(), "get2");