diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateDelegateHandler.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateDelegateHandler.java index 6aafba515e00..1818c9b56a05 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateDelegateHandler.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateDelegateHandler.java @@ -405,6 +405,9 @@ public class GenerateDelegateHandler implements LanguageCodeInsightActionHandler final PsiVariable psiVariable = proc.getResult(i); final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(aClass.getProject()); final PsiType type = psiVariable.getType(); + if (LambdaUtil.notInferredType(type)) { + continue; + } result.add(new PsiFieldMember(elementFactory.createField(psiVariable.getName(), type instanceof PsiEllipsisType ? ((PsiEllipsisType)type).toArrayType() : type)) { @Override protected PsiClass getContainingClass() { diff --git a/java/java-tests/testData/codeInsight/delegateMethods/afterInsideLambdaWithNonInferredTypeParameters.java b/java/java-tests/testData/codeInsight/delegateMethods/afterInsideLambdaWithNonInferredTypeParameters.java new file mode 100644 index 000000000000..91b0e65c5dc5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/delegateMethods/afterInsideLambdaWithNonInferredTypeParameters.java @@ -0,0 +1,17 @@ + +import java.util.function.Function; + +class Test { + + public void foo() { + + foo(s -> { + new Function() { + { + + } + } + }) + + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/delegateMethods/beforeInsideLambdaWithNonInferredTypeParameters.java b/java/java-tests/testData/codeInsight/delegateMethods/beforeInsideLambdaWithNonInferredTypeParameters.java new file mode 100644 index 000000000000..91b0e65c5dc5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/delegateMethods/beforeInsideLambdaWithNonInferredTypeParameters.java @@ -0,0 +1,17 @@ + +import java.util.function.Function; + +class Test { + + public void foo() { + + foo(s -> { + new Function() { + { + + } + } + }) + + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/DelegateMethodsTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/DelegateMethodsTest.java index 6b46e50ff874..c46499fe442f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/DelegateMethodsTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/DelegateMethodsTest.java @@ -92,6 +92,10 @@ public class DelegateMethodsTest extends LightCodeInsightTestCase { doTest(); } + public void testInsideLambdaWithNonInferredTypeParameters() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(getTestName(false)); }