mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 06:39:38 +07:00
most specific: infer specific if method is generic even if type arguments are explicitly provided
This commit is contained in:
@@ -602,7 +602,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
@NotNull PsiMethod method2) {
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && method1.getTypeParameters().length > 0 && myArgumentsList instanceof PsiExpressionList) {
|
||||
final PsiElement parent = myArgumentsList.getParent();
|
||||
if (parent instanceof PsiCallExpression && ((PsiCallExpression)parent).getTypeArguments().length == 0) {
|
||||
if (parent instanceof PsiCallExpression) {
|
||||
return InferenceSession.isMoreSpecific(method2, method1, ((PsiExpressionList)myArgumentsList).getExpressions(), myArgumentsList, varargsPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class Test<T> {
|
||||
Test(T arg) {}
|
||||
Test(String arg) {}
|
||||
static <X> Test<X> m(X arg) {return null;}
|
||||
static <X> Test<X> m(String arg) {return null;}
|
||||
|
||||
{
|
||||
m("");
|
||||
Test.<String>m("");
|
||||
new Test<>("");
|
||||
new Test<String><error descr="Cannot resolve constructor 'Test(java.lang.String)'">("")</error>;
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,10 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testInferSpecificForGenericMethodWhenCallProvidesExplicitTypeArguments() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user