mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
skip inference for incompatible method references
EA-103416 - assert: PsiMethodReferenceCompatibilityConstraint.getSubstitutor
This commit is contained in:
+5
-4
@@ -249,10 +249,11 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
final PsiResolveHelper helper = JavaPsiFacade.getInstance(methodReferenceExpression.getProject()).getResolveHelper();
|
||||
final PsiType[] paramTypes =
|
||||
member instanceof PsiMethod ? ((PsiMethod)member).getSignature(PsiSubstitutor.EMPTY).getParameterTypes() : PsiType.EMPTY_ARRAY;
|
||||
LOG.assertTrue(paramTypes.length == signature.getParameterTypes().length ||
|
||||
member instanceof PsiMethod && ((PsiMethod)member).isVarArgs(), "expr: " + methodReferenceExpression + "; " +
|
||||
paramTypes.length + "; " +
|
||||
Arrays.toString(signature.getParameterTypes()));
|
||||
|
||||
if (paramTypes.length != signature.getParameterTypes().length && !(member instanceof PsiMethod && ((PsiMethod)member).isVarArgs())) {
|
||||
//inapplicable method reference
|
||||
return PsiSubstitutor.EMPTY;
|
||||
}
|
||||
if (Arrays.deepEquals(signature.getParameterTypes(), paramTypes)) {
|
||||
return PsiSubstitutor.EMPTY;
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import java.util.function.IntFunction;
|
||||
|
||||
class Outer<K> {
|
||||
public Outer() { }
|
||||
|
||||
{
|
||||
//wrong number of parameters as well as a wrong expected type
|
||||
final IntFunction<Outer[]> aNew = <error descr="Bad return type in method reference: cannot convert Outer to Outer[]">Outer::new</error>;
|
||||
}
|
||||
}
|
||||
+1
@@ -179,6 +179,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testConstructorReferenceWithVarargsParameters() { doTest(); }
|
||||
public void testMethodReferenceSwallowedErrors() { doTest(); }
|
||||
public void testConflictingVarargsFromFirstSearchWithNArityOfTheSecondSearch() { doTest(); }
|
||||
public void testSkipInferenceForInapplicableMethodReference() { doTest(); }
|
||||
|
||||
public void testPreferErrorOnTopLevelToFailedSubstitutorOnNestedLevel() { doTest(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user