applicability error: check inferred types by applicability substitutor (IDEA-167275)

This commit is contained in:
Anna.Kozlova
2017-02-13 14:10:51 +01:00
parent dfe0c02166
commit abfa41efdf
3 changed files with 32 additions and 3 deletions
@@ -429,11 +429,12 @@ public class HighlightMethodUtil {
else {
PsiReferenceExpression methodExpression = methodCall.getMethodExpression();
PsiReferenceParameterList typeArgumentList = methodCall.getTypeArgumentList();
PsiSubstitutor applicabilitySubstitutor = candidateInfo.getSubstitutor(false);
if (typeArgumentList.getTypeArguments().length == 0 && resolvedMethod.hasTypeParameters()) {
highlightInfo = GenericsHighlightUtil.checkInferredTypeArguments(resolvedMethod, methodCall, substitutor);
highlightInfo = GenericsHighlightUtil.checkInferredTypeArguments(resolvedMethod, methodCall, applicabilitySubstitutor);
}
else {
highlightInfo = GenericsHighlightUtil.checkParameterizedReferenceTypeArguments(resolved, methodExpression, substitutor, javaSdkVersion);
highlightInfo = GenericsHighlightUtil.checkParameterizedReferenceTypeArguments(resolved, methodExpression, applicabilitySubstitutor, javaSdkVersion);
}
}
}
@@ -0,0 +1,24 @@
import java.util.function.Function;
class Test {
public static void main(Builder<Beta> gammaBuilder) {
<error descr="Inferred type 'B' for type parameter 'B' is not within its bound; should extend 'Test.Builder<Test.Alfa>'">a(Test::c, name -> gammaBuilder)</error>;
}
private static <T extends Alfa, B extends Builder<T>> void a(final Function<B, String> f1,
final Function<String, B> f2) {
}
private static String c(final Builder<? extends Beta> builder) {
return "";
}
static class Alfa {}
private static class Beta extends Alfa {}
static class Builder<T> {}
}
@@ -517,7 +517,11 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testMethodReferenceSecondSearchDontInfluenceTopSiteSubstitutor() throws Exception {
public void testApplicabilityErrorVisibleWhenConstraintsFromFunctionalExpressionsProvideValidSubstitutor() throws Exception {
doTest();
}
public void testExactMethodReferenceWithWildcardBound() throws Exception {
doTest();
}