mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
method refs: infer 'diamond' if constructor ref type is raw (IDEA-142142)
This commit is contained in:
+13
@@ -227,6 +227,19 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
psiSubstitutor = TypeConversionUtil.getClassSubstitutor(qContainingClass, paramClass, resolveResult.getSubstitutor());
|
||||
LOG.assertTrue(psiSubstitutor != null);
|
||||
}
|
||||
else if (member instanceof PsiMethod && ((PsiMethod)member).isConstructor() || member instanceof PsiClass) {
|
||||
//15.13.1
|
||||
//If ClassType is a raw type, but is not a non-static member type of a raw type,
|
||||
//the candidate notional member methods are those specified in §15.9.3 for a class instance creation expression that uses <>
|
||||
//to elide the type arguments to a class.
|
||||
final PsiResolveHelper helper = JavaPsiFacade.getInstance(myExpression.getProject()).getResolveHelper();
|
||||
final PsiType[] paramTypes =
|
||||
member instanceof PsiMethod ? ((PsiMethod)member).getSignature(PsiSubstitutor.EMPTY).getParameterTypes() : PsiType.EMPTY_ARRAY;
|
||||
psiSubstitutor = helper.inferTypeArguments(qContainingClass.getTypeParameters(),
|
||||
paramTypes,
|
||||
signature.getParameterTypes(),
|
||||
PsiUtil.getLanguageLevel(myExpression));
|
||||
}
|
||||
else {
|
||||
psiSubstitutor = PsiSubstitutor.EMPTY;
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import java.util.*;
|
||||
class Test {
|
||||
public Optional<Set<String>> foo(Optional<Set<String>> args) {
|
||||
return args.map(HashSet::new).map(Collections::unmodifiableSet);
|
||||
}
|
||||
}
|
||||
+4
@@ -414,6 +414,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRawClassTypeOnConstructorReference() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user