mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
overload resolution: don't include constraints on functional expressions into applicability check during overload resolution (IDEA-150745)
This commit is contained in:
@@ -136,6 +136,8 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
@ApplicabilityLevelConstant int level = computeForOverloadedCandidate(new Computable<Integer>() {
|
||||
@Override
|
||||
public Integer compute() {
|
||||
//arg types are calculated here without additional constraints:
|
||||
//non-pertinent to applicability arguments of arguments would be skipped
|
||||
PsiType[] argumentTypes = getArgumentTypes();
|
||||
if (argumentTypes == null) {
|
||||
return ApplicabilityLevel.NOT_APPLICABLE;
|
||||
|
||||
@@ -358,7 +358,7 @@ public class InferenceSession {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parameters != null && args != null) {
|
||||
if (parameters != null && args != null && !MethodCandidateInfo.isOverloadCheck()) {
|
||||
final Set<ConstraintFormula> additionalConstraints = new LinkedHashSet<ConstraintFormula>();
|
||||
if (parameters.length > 0) {
|
||||
collectAdditionalConstraints(parameters, args, properties.getMethod(), mySiteSubstitutor, additionalConstraints, properties.isVarargs(), initialSubstitutor);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2016. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package usages;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
class Test {
|
||||
{
|
||||
valueOf(processFirst(<error descr="no instance(s) of type variable(s) exist so that Integer conforms to char[]">x -> x</error>));
|
||||
}
|
||||
|
||||
public static <V> V processFirst(Function<Integer,V> f){
|
||||
return f.apply(1);
|
||||
}
|
||||
static void valueOf(Object o) {
|
||||
System.out.println(o);
|
||||
}
|
||||
static void valueOf(char[] c) {
|
||||
System.out.println(c);
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,13 @@ import java.util.stream.Stream;
|
||||
class Test {
|
||||
|
||||
void foo() {
|
||||
log(get(TreeSet<String>::new));
|
||||
log(get(<error descr="Bad return type in method reference: cannot convert java.util.TreeSet<java.lang.String> to C">TreeSet<String>::new</error>));
|
||||
}
|
||||
|
||||
private void <warning descr="Private method 'log(java.lang.String[])' is never used">log</warning>(String params[]) {
|
||||
private void log(String params[]) {
|
||||
System.out.println(params);
|
||||
}
|
||||
private void log(Object params) {
|
||||
private void <warning descr="Private method 'log(java.lang.Object)' is never used">log</warning>(Object params) {
|
||||
System.out.println(params);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,6 +196,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testDonotIncludeAdditionalConstraintsDuringApplicabilityChecksInsideOverloadResolution() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user