overload resolution: erase type of parameter when site substitutor is raw (IDEA-203450)

similar to erasure of call type when inferred substitutor is raw
This commit is contained in:
Anna.Kozlova
2018-12-03 14:33:04 +01:00
parent 1afc043792
commit d2042376d2
3 changed files with 31 additions and 0 deletions

View File

@@ -1720,6 +1720,9 @@ public class InferenceSession {
for (int i = 0; i < paramsLength; i++) {
PsiType sType = getParameterType(parameters1, i, siteSubstitutor1, false);
PsiType tType = session.substituteWithInferenceVariables(getParameterType(parameters2, i, siteSubstitutor1, varargs));
if (PsiUtil.isRawSubstitutor(m2, siteSubstitutor1)) {
tType = TypeConversionUtil.erasure(tType);
}
if (sType instanceof PsiClassType &&
tType instanceof PsiClassType &&
LambdaUtil.isFunctionalType(sType) && LambdaUtil.isFunctionalType(tType) && !relates(sType, tType)) {

View File

@@ -0,0 +1,26 @@
import java.util.HashSet;
import java.util.Set;
class TestCaller1<P1> {
{
TestCaller1.foo(null);
}
public static void foo(HashSet<Integer> fn) { }
public <P> void foo(Set<String> fn) { }
}
class TestCaller2 {
{
TestCaller2.foo<error descr="Ambiguous method call: both 'TestCaller2.foo(HashSet<Integer>)' and 'TestCaller2.foo(Set<String>)' match">(null)</error>;
}
public static void foo(HashSet<Integer> fn) { }
public <P> void foo(Set<String> fn) { }
}
class TestCaller3 {
{
TestCaller2.foo<error descr="Ambiguous method call: both 'TestCaller2.foo(HashSet<Integer>)' and 'TestCaller2.foo(Set<String>)' match">(null)</error>;
}
public static void foo(HashSet<Integer> fn) { }
public static void foo(Set<String> fn) { }
}

View File

@@ -270,6 +270,8 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
public void testOverriddenMethodWithOtherRawSignature() { doTest(false);}
public void testMoreSpecificForRawSignatureOnStaticProblem() { doTest(false);}
public void testUnqualifiedStaticInterfaceMethodCallsOnInnerClasses() { doTest(false);}
public void testStaticMethodInSuperInterfaceConflictWithCurrentStatic() { doTest(false);}