java completion: don't insert method type arguments if they weren't inferred (IDEA-198368)

This commit is contained in:
peter
2019-01-10 15:22:42 +01:00
parent 283f630e70
commit 70a719c87a
4 changed files with 54 additions and 1 deletions
@@ -457,7 +457,8 @@ public class JavaMethodCallElement extends LookupItem<PsiMethod> implements Type
List<PsiType> substituted = ContainerUtil.map(parameters, parameter -> {
PsiType type = substitutor.substitute(parameter);
return type instanceof PsiWildcardType ? ((PsiWildcardType)type).getExtendsBound() : type;
if (type instanceof PsiWildcardType) type = ((PsiWildcardType)type).getExtendsBound();
return PsiUtil.resolveClassInClassTypeOnly(type) == parameter ? null : type;
});
if (ContainerUtil.exists(substituted, t -> t == null || t instanceof PsiCapturedWildcardType)) return null;
if (substituted.equals(ContainerUtil.map(parameters, TypeConversionUtil::typeParameterErasure))) return null;
@@ -0,0 +1,18 @@
import java.util.Comparator;
class T {
{
new TreeSet<>(Ordering.na<caret>)
}
}
abstract class Ordering<T> implements Comparator<T> {
static <C extends Comparable> Ordering<C> natural() {
}
}
class TreeSet<E> {
TreeSet(Comparator<? super E> c) {
}
}
@@ -0,0 +1,18 @@
import java.util.Comparator;
class T {
{
new TreeSet<>(Ordering.natural()<caret>)
}
}
abstract class Ordering<T> implements Comparator<T> {
static <C extends Comparable> Ordering<C> natural() {
}
}
class TreeSet<E> {
TreeSet(Comparator<? super E> c) {
}
}
@@ -0,0 +1,16 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.completion
import com.intellij.testFramework.LightProjectDescriptor
import groovy.transform.CompileStatic
/**
* @author peter
*/
@CompileStatic
class Normal7CompletionTest extends NormalCompletionTestCase {
final LightProjectDescriptor projectDescriptor = JAVA_1_7
void testGenericInsideDiamond() { doTest() }
}