diff --git a/java/java-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java b/java/java-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java index 5ab8414c0690..c28b084908ae 100644 --- a/java/java-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/streamMigration/StreamApiMigrationInspection.java @@ -993,7 +993,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo operationName = "mapToObj"; } PsiExpression expression = myType == null ? myExpression : RefactoringUtil.convertInitializerToNormalExpression(myExpression, myType); - if(myType != null && !(myType instanceof PsiPrimitiveType)) { + if(myType != null && !(myType instanceof PsiPrimitiveType) && !(myType instanceof PsiCapturedWildcardType)) { operationName = "<"+myType.getCanonicalText()+">"+operationName; } return "." + operationName + "(" + LambdaUtil.createLambda(myVariable, expression) + ")"; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterWildcardCollect.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterWildcardCollect.java new file mode 100644 index 000000000000..32de155be277 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/afterWildcardCollect.java @@ -0,0 +1,11 @@ +// "Replace with collect" "true" +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +class A { + public List sum() { + List result = IntStream.range(0, 10).mapToObj(i -> i * 2).collect(Collectors.toList()); + return result; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeWildcardCollect.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeWildcardCollect.java new file mode 100644 index 000000000000..c6961f75df37 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamApiMigration/beforeWildcardCollect.java @@ -0,0 +1,12 @@ +// "Replace with collect" "true" +import java.util.*; + +class A { + public List sum() { + List result = new ArrayList<>(); + for(int i=0; i<10; i++) { + result.add(i*2); + } + return result; + } +} \ No newline at end of file