lambda: process lambda as parameter for anonymous class (IDEA-116987)

This commit is contained in:
anna
2013-11-25 18:22:57 +01:00
parent 383ad37cac
commit bf64625fb2
3 changed files with 29 additions and 1 deletions

View File

@@ -455,7 +455,12 @@ public class LambdaUtil {
if (!tryToSubstitute) return cachedType;
}
final PsiElement gParent = expressionList.getParent();
PsiElement gParent = expressionList.getParent();
if (gParent instanceof PsiAnonymousClass) {
gParent = gParent.getParent();
}
if (gParent instanceof PsiCall) {
final PsiCall contextCall = (PsiCall)gParent;
final JavaResolveResult resolveResult = contextCall.resolveMethodGenerics();

View File

@@ -0,0 +1,19 @@
interface I<T> {
void accept(T t);
}
class LamdbaTest<T> {
public void f() {
new A<T>(t -> g(t)) {};
}
private void g(T t) {
}
class A<T2> {
public A(I<T> editor) {
}
}
}

View File

@@ -82,6 +82,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testArgumentOfAnonymousClass() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}