diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index 2c6bc42c71b..f2a672e1c6b 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -42435,12 +42435,6 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt"); } - @Test - @TestMetadata("streams.kt") - public void testStreams() { - runTest("compiler/testData/diagnostics/testsWithStdLib/streams.kt"); - } - @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") @TestDataPath("$PROJECT_ROOT") @@ -47057,6 +47051,28 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia } } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/streams") + @TestDataPath("$PROJECT_ROOT") + public class Streams { + @Test + public void testAllFilesPresentInStreams() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/streams"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/basic.kt"); + } + + @Test + @TestMetadata("wrongNullability.kt") + public void testWrongNullability() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns") @TestDataPath("$PROJECT_ROOT") diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index dda9c9135e9..1f0574488e8 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -42435,12 +42435,6 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt"); } - @Test - @TestMetadata("streams.kt") - public void testStreams() { - runTest("compiler/testData/diagnostics/testsWithStdLib/streams.kt"); - } - @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") @TestDataPath("$PROJECT_ROOT") @@ -47057,6 +47051,28 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated } } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/streams") + @TestDataPath("$PROJECT_ROOT") + public class Streams { + @Test + public void testAllFilesPresentInStreams() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/streams"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/basic.kt"); + } + + @Test + @TestMetadata("wrongNullability.kt") + public void testWrongNullability() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 81ff14587bf..0df6a78ec51 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -40007,12 +40007,6 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt"); } - @Test - @TestMetadata("streams.kt") - public void testStreams() { - runTest("compiler/testData/diagnostics/testsWithStdLib/streams.kt"); - } - @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") @TestDataPath("$PROJECT_ROOT") @@ -44687,6 +44681,28 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir } } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/streams") + @TestDataPath("$PROJECT_ROOT") + public class Streams { + @Test + public void testAllFilesPresentInStreams() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/streams"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/basic.kt"); + } + + @Test + @TestMetadata("wrongNullability.kt") + public void testWrongNullability() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 1b5a645f55f..0f9101c25fc 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -40145,12 +40145,6 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt"); } - @Test - @TestMetadata("streams.kt") - public void testStreams() { - runTest("compiler/testData/diagnostics/testsWithStdLib/streams.kt"); - } - @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") @TestDataPath("$PROJECT_ROOT") @@ -44825,6 +44819,28 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia } } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/streams") + @TestDataPath("$PROJECT_ROOT") + public class Streams { + @Test + public void testAllFilesPresentInStreams() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/streams"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/basic.kt"); + } + + @Test + @TestMetadata("wrongNullability.kt") + public void testWrongNullability() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/diagnostics/testsWithStdLib/streams.txt b/compiler/testData/diagnostics/testsWithStdLib/streams.txt deleted file mode 100644 index f8a8fa2235a..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/streams.txt +++ /dev/null @@ -1,3 +0,0 @@ -package - -public fun testStreams(/*0*/ list: java.util.ArrayList): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/streams.kt b/compiler/testData/diagnostics/testsWithStdLib/streams/basic.kt similarity index 100% rename from compiler/testData/diagnostics/testsWithStdLib/streams.kt rename to compiler/testData/diagnostics/testsWithStdLib/streams/basic.kt diff --git a/compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.fir.kt new file mode 100644 index 00000000000..6fb17a78eb0 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.fir.kt @@ -0,0 +1,24 @@ +// FULL_JDK +// JVM_TARGET: 1.8 + +import java.util.function.IntPredicate +import java.util.stream.Stream +import kotlin.streams.toList + +class IntLongPair(val i: Int, val l: Long) + +interface Process { + fun pid(): Int + + fun totalCpuDuration(): Long? +} + +fun run(filter: IntPredicate, allProcesses: Stream): List { + return allProcesses.filter { + filter.test(it.pid()) + }.map { + val duration = it.totalCpuDuration() + if (duration != null) IntLongPair(it.pid(), duration) + else null + }.toList() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.kt b/compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.kt new file mode 100644 index 00000000000..3f321c79605 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.kt @@ -0,0 +1,24 @@ +// FULL_JDK +// JVM_TARGET: 1.8 + +import java.util.function.IntPredicate +import java.util.stream.Stream +import kotlin.streams.toList + +class IntLongPair(val i: Int, val l: Long) + +interface Process { + fun pid(): Int + + fun totalCpuDuration(): Long? +} + +fun run(filter: IntPredicate, allProcesses: Stream): List { + return allProcesses.filter { + filter.test(it.pid()) + }.map { + val duration = it.totalCpuDuration() + if (duration != null) IntLongPair(it.pid(), duration) + else null + }.toList() +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 0a5e41f05f5..dbe5cf5da96 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -42435,12 +42435,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/shadowingInDestructuring.kt"); } - @Test - @TestMetadata("streams.kt") - public void testStreams() { - runTest("compiler/testData/diagnostics/testsWithStdLib/streams.kt"); - } - @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") @TestDataPath("$PROJECT_ROOT") @@ -47115,6 +47109,28 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } } + @Nested + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/streams") + @TestDataPath("$PROJECT_ROOT") + public class Streams { + @Test + public void testAllFilesPresentInStreams() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/streams"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("basic.kt") + public void testBasic() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/basic.kt"); + } + + @Test + @TestMetadata("wrongNullability.kt") + public void testWrongNullability() { + runTest("compiler/testData/diagnostics/testsWithStdLib/streams/wrongNullability.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns") @TestDataPath("$PROJECT_ROOT")