mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
completion for inherited after new: find corresponding type parameter when target type passes to another parameter (IDEA-157803)
This commit is contained in:
@@ -366,6 +366,12 @@ public class CodeInsightUtil {
|
||||
for (PsiTypeParameter inheritorParameter : PsiUtil.typeParametersIterable(inheritor)) {
|
||||
for (PsiTypeParameter baseParameter : PsiUtil.typeParametersIterable(baseClass)) {
|
||||
final PsiType substituted = superSubstitutor.substitute(baseParameter);
|
||||
PsiClass inheritorCandidateParameter = PsiUtil.resolveClassInType(substituted);
|
||||
if (inheritorCandidateParameter instanceof PsiTypeParameter &&
|
||||
((PsiTypeParameter)inheritorCandidateParameter).getOwner() == inheritor &&
|
||||
inheritorCandidateParameter != inheritorParameter) {
|
||||
continue;
|
||||
}
|
||||
PsiType arg = baseSubstitutor.substitute(baseParameter);
|
||||
if (arg instanceof PsiWildcardType) {
|
||||
PsiType bound = ((PsiWildcardType)arg).getBound();
|
||||
@@ -376,7 +382,7 @@ public class CodeInsightUtil {
|
||||
arg,
|
||||
true,
|
||||
PsiUtil.getLanguageLevel(context));
|
||||
if (PsiType.NULL.equals(substitution) || substitution != null && substitution.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || substitution instanceof PsiWildcardType) continue;
|
||||
if (PsiType.NULL.equals(substitution) || substitution instanceof PsiWildcardType) continue;
|
||||
if (substitution == null) {
|
||||
result.consume(createType(inheritor, facade.getElementFactory().createRawSubstitutor(inheritor), arrayDim));
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class M<K, V> {}
|
||||
class HM<K, V> extends M<K, V> {}
|
||||
class Foo {
|
||||
{
|
||||
M<String, Object> m = new <caret>
|
||||
}
|
||||
}
|
||||
+5
@@ -233,6 +233,11 @@ public void testConvertToObjectStream() {
|
||||
assertOrderedEquals(myFixture.getLookupElementStrings(), "get2");
|
||||
}
|
||||
|
||||
public void testInferredObjects() {
|
||||
configureByTestName();
|
||||
assertOrderedEquals(myFixture.getLookupElementStrings(), "M", "HM");
|
||||
}
|
||||
|
||||
public void testSuggestMapInheritors() { doTest(); }
|
||||
|
||||
public void testUnboundTypeArgs() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user