most specific: infer specific if method is generic even if type arguments are explicitly provided

This commit is contained in:
Anna Kozlova
2015-02-13 16:30:40 +01:00
parent 925e9d1610
commit 465879cacf
3 changed files with 18 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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>;
}
}

View File

@@ -122,6 +122,10 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
doTest(false);
}
public void testInferSpecificForGenericMethodWhenCallProvidesExplicitTypeArguments() throws Exception {
doTest(false);
}
private void doTest() {
doTest(true);
}