mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] tolerate recursive applicability check
EA-239076 - NPE: MethodCandidateInfo.inferTypeArguments; possible if `var` type variable contains self reference in its initializer GitOrigin-RevId: b0fb15c563d41b5124a381988e335162c723cd5e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
953c7acd84
commit
c0dc171db2
@@ -164,8 +164,11 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
}
|
||||
return level1;
|
||||
}, substitutor);
|
||||
@ApplicabilityLevelConstant int level =
|
||||
Objects.requireNonNull(ourOverloadGuard.doPreventingRecursion(myArgumentList, false, computable));
|
||||
Integer applicabilityLevel = ourOverloadGuard.doPreventingRecursion(myArgumentList, false, computable);
|
||||
if (applicabilityLevel == null) {
|
||||
return ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
@ApplicabilityLevelConstant int level = applicabilityLevel;
|
||||
if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable(() -> substitutor)) {
|
||||
level = ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.function.Function;
|
||||
|
||||
class MyTest {
|
||||
|
||||
<T> java.util.List<T> f(Function<T, String> ff) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void test() {
|
||||
var t = this.<String><caret>f(t);
|
||||
}
|
||||
}
|
||||
+9
@@ -12,6 +12,8 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiMethodCallExpression;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
|
||||
public class LightAdvLVTIHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
@@ -56,6 +58,13 @@ public class LightAdvLVTIHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testFailedInferenceWithLeftTypeVar() { doTest(); }
|
||||
public void testDisjunctionType() { doTest(); }
|
||||
|
||||
public void testRecursiveInference() {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
final int offset = getEditor().getCaretModel().getOffset();
|
||||
PsiMethodCallExpression expression = PsiTreeUtil.getParentOfType(getFile().findElementAt(offset), PsiMethodCallExpression.class);
|
||||
assertTrue(expression.resolveMethodGenerics().isValidResult());
|
||||
}
|
||||
|
||||
public void testVarInLambdaParameters() {
|
||||
setLanguageLevel(LanguageLevel.JDK_11);
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user