mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
new overload resolution: don't treat array type of functional interfaces as functional interface (IDEA-148726)
This commit is contained in:
@@ -1510,7 +1510,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 (LambdaUtil.isFunctionalType(sType) && LambdaUtil.isFunctionalType(tType) && !relates(sType, tType)) {
|
||||
if (sType instanceof PsiClassType &&
|
||||
tType instanceof PsiClassType &&
|
||||
LambdaUtil.isFunctionalType(sType) && LambdaUtil.isFunctionalType(tType) && !relates(sType, tType)) {
|
||||
if (!isFunctionalTypeMoreSpecific(sType, tType, session, args[i])) {
|
||||
return false;
|
||||
}
|
||||
@@ -1590,7 +1592,8 @@ public class InferenceSession {
|
||||
|
||||
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions((PsiLambdaExpression)arg);
|
||||
|
||||
if (LambdaUtil.isFunctionalType(sReturnType) && LambdaUtil.isFunctionalType(tReturnType) &&
|
||||
if (sReturnType instanceof PsiClassType && tReturnType instanceof PsiClassType &&
|
||||
LambdaUtil.isFunctionalType(sReturnType) && LambdaUtil.isFunctionalType(tReturnType) &&
|
||||
!TypeConversionUtil.isAssignable(TypeConversionUtil.erasure(sReturnType), TypeConversionUtil.erasure(tReturnType)) &&
|
||||
!TypeConversionUtil.isAssignable(TypeConversionUtil.erasure(tReturnType), TypeConversionUtil.erasure(sReturnType))) {
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class Test {
|
||||
private static <T> void test(Class<T> cls, Runnable... objs) {
|
||||
System.out.println(cls);
|
||||
System.out.println(objs);
|
||||
}
|
||||
|
||||
private static <K> void <warning descr="Private method 'test(K, java.lang.Runnable...)' is never used">test</warning>(K obj, Runnable... objs) {
|
||||
System.out.println(obj);
|
||||
System.out.println(objs);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
test(String.class, new Runnable[1]);
|
||||
}
|
||||
}
|
||||
@@ -179,6 +179,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFunctionalInterfacesAtVarargsPositionMostSpecificCheck() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user