From 0c195be513c6c13860910ff1afb0ba588360dcd7 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 6 Feb 2020 16:30:16 +0300 Subject: [PATCH] [FIR TEST] Add test with MutableMap.compute --- .../testData/resolve/stdlib/j+k/MapCompute.kt | 11 +++++++++++ .../testData/resolve/stdlib/j+k/MapCompute.txt | 17 +++++++++++++++++ .../FirDiagnosticsWithStdlibTestGenerated.java | 5 +++++ 3 files changed, 33 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.kt create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.txt diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.kt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.kt new file mode 100644 index 00000000000..14ba2b3c11f --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.kt @@ -0,0 +1,11 @@ +// FULL_JDK +// STDLIB_JDK8 +// !JVM_TARGET: 1.8 + +fun MutableMap>.initAndAdd(key: String, value: D) { + this.compute(key) { _, maybeValues -> + val setOfValues = maybeValues ?: mutableSetOf() + setOfValues.add(value) + setOfValues + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.txt new file mode 100644 index 00000000000..a7cc7ba0a84 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.txt @@ -0,0 +1,17 @@ +FILE: MapCompute.kt + public final fun R|kotlin/collections/MutableMap>|.initAndAdd(key: R|kotlin/String|, value: R|D|): R|kotlin/Unit| { + this@R|/initAndAdd|.#(R|/key|, = compute@fun (_: R|ERROR CLASS: No type for parameter|, maybeValues: R|ERROR CLASS: No type for parameter|): R|ERROR CLASS: Unresolved: | { + lval setOfValues: R|ERROR CLASS: Unresolved: | = when (lval : R|ERROR CLASS: No type for parameter| = R|/maybeValues|) { + ==($subj$, Null(null)) -> { + R|kotlin/collections/mutableSetOf|() + } + else -> { + R|/| + } + } + + R|/setOfValues|.#(R|/value|) + ^ R|/setOfValues| + } + ) + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index d7c07944881..b59aab8dbae 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -544,6 +544,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolve/stdlib/j+k/LoggerInstance.kt"); } + @TestMetadata("MapCompute.kt") + public void testMapCompute() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/j+k/MapCompute.kt"); + } + @TestMetadata("MapEntry.kt") public void testMapEntry() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.kt");