lambda: infer functional interface from enum constants (IDEA-97596)

This commit is contained in:
anna
2012-12-17 17:32:28 +01:00
parent f038ae950e
commit 44ab4d534a
3 changed files with 18 additions and 4 deletions
@@ -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;
@@ -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);
}
}
@@ -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);
}