mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
lambda: infer functional interface from enum constants (IDEA-97596)
This commit is contained in:
@@ -405,8 +405,8 @@ public class LambdaUtil {
|
||||
}
|
||||
|
||||
final PsiElement gParent = expressionList.getParent();
|
||||
if (gParent instanceof PsiCallExpression) {
|
||||
final PsiCallExpression contextCall = (PsiCallExpression)gParent;
|
||||
if (gParent instanceof PsiCall) {
|
||||
final PsiCall contextCall = (PsiCall)gParent;
|
||||
final JavaResolveResult resolveResult = contextCall.resolveMethodGenerics();
|
||||
final PsiElement resolve = resolveResult.getElement();
|
||||
if (resolve instanceof PsiMethod) {
|
||||
@@ -578,11 +578,11 @@ public class LambdaUtil {
|
||||
}
|
||||
if (parent instanceof PsiExpressionList) {
|
||||
final PsiElement gParent = parent.getParent();
|
||||
if (gParent instanceof PsiCallExpression) {
|
||||
if (gParent instanceof PsiCall) {
|
||||
final Map<PsiElement, PsiMethod> map = MethodCandidateInfo.CURRENT_CANDIDATE.get();
|
||||
myMethod = map != null ? map.get(parent) : null;
|
||||
if (myMethod == null) {
|
||||
myMethod = ((PsiCallExpression)gParent).resolveMethod();
|
||||
myMethod = ((PsiCall)gParent).resolveMethod();
|
||||
}
|
||||
if (myMethod != null && PsiTreeUtil.isAncestor(myMethod, expression, false)) {
|
||||
myMethod = null;
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
enum Bug {
|
||||
INSTANCE1((Integer x, Integer y) -> x.byteValue()),
|
||||
INSTANCE2((x, y) -> y. byteValue());
|
||||
private Bug(Foo foo) {
|
||||
}
|
||||
|
||||
private interface Foo {
|
||||
byte bar(Integer x, Integer y);
|
||||
}
|
||||
}
|
||||
+4
@@ -161,6 +161,10 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testEnumConstants() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user