diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapWithAdapterMethodCallFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapWithAdapterMethodCallFix.java index 1cc0f9b3ea24..d201adb66a02 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapWithAdapterMethodCallFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapWithAdapterMethodCallFix.java @@ -61,8 +61,13 @@ public class WrapWithAdapterMethodCallFix extends LocalQuickFixAndIntentionActio !myOutTypeFilter.test(outType)) { return false; } - PsiType resultType = - createReplacement(context, "((" + GenericsUtil.getVariableTypeByExpressionType(inType).getCanonicalText() + ")null)").getType(); + PsiType variableType = GenericsUtil.getVariableTypeByExpressionType(inType); + String typeText = variableType.getCanonicalText(); + if(!variableType.equalsToText(typeText)) { + // Probably some incorrect type like PsiLambdaParameterType + return false; + } + PsiType resultType = createReplacement(context, "((" + typeText + ")null)").getType(); return resultType != null && outType.isAssignableFrom(resultType); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/wrapAdapterCall/beforeUnresolved.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/wrapAdapterCall/beforeUnresolved.java new file mode 100644 index 000000000000..29bc5f6444a7 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/wrapAdapterCall/beforeUnresolved.java @@ -0,0 +1,6 @@ +// "Wrap parameter using 'new File()'" "false" +class Foo { + private static Y[] parse(Iterable ss) { + return Y.toArray(X.from(ss).transform(s -> parse(s))); + } +} \ No newline at end of file