From dc750cdbb33ae2e80b98b2b3f17cb25b4efa3308 Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Thu, 11 Oct 2018 12:49:39 +0900 Subject: [PATCH] Call chain into sequence: add 'unzip' to conversion targets #KT-27486 Fixed --- .../collections/ConvertCallChainIntoSequenceInspection.kt | 3 ++- .../convertCallChainIntoSequence/termination/unzip.kt | 5 +++++ .../convertCallChainIntoSequence/termination/unzip.kt.after | 5 +++++ .../idea/inspections/LocalInspectionTestGenerated.java | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt create mode 100644 idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/collections/ConvertCallChainIntoSequenceInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/collections/ConvertCallChainIntoSequenceInspection.kt index d062809500a..7936f5e33b0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/collections/ConvertCallChainIntoSequenceInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/collections/ConvertCallChainIntoSequenceInspection.kt @@ -304,7 +304,8 @@ private val terminations = listOf( "toMutableList", "toMutableSet", "toSet", - "toSortedSet" + "toSortedSet", + "unzip" ).associate { val pkg = if (it in listOf("contains", "indexOf", "lastIndexOf")) "kotlin.collections.List" else "kotlin.collections" it to FqName("$pkg.$it") diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt new file mode 100644 index 00000000000..7f197e91128 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test() { + val pair: Pair, List> = listOf(1 to 2, 3 to 4).filter { it.first > 1 }.filter { it.second > 2 }.unzip() +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt.after b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt.after new file mode 100644 index 00000000000..8eb86e4cf48 --- /dev/null +++ b/idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt.after @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun test() { + val pair: Pair, List> = listOf(1 to 2, 3 to 4).asSequence().filter { it.first > 1 }.filter { it.second > 2 }.unzip() +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 0cff48d51e3..051258096b4 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -1010,6 +1010,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { public void testToSortedSet() throws Exception { runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/toSortedSet.kt"); } + + @TestMetadata("unzip.kt") + public void testUnzip() throws Exception { + runTest("idea/testData/inspectionsLocal/collections/convertCallChainIntoSequence/termination/unzip.kt"); + } } }