From 15a0157c42ca720cce63d9d8fbf27b9fcd971433 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 6 Mar 2020 18:09:40 +0300 Subject: [PATCH] FIR: Support proper loading of Map.merge --- .../org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt | 4 ++++ .../fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.kt | 5 +++++ .../resolve/testData/resolveWithStdlib/j+k/mapMerge.txt | 7 +++++++ .../kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java | 5 +++++ 4 files changed, 21 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.kt create mode 100644 compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.txt diff --git a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt index 64483537608..a32f5cf6a7a 100644 --- a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt +++ b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt @@ -116,6 +116,10 @@ private fun StringBuilder.appendConeType(coneType: ConeKotlinType) { appendClassLikeType(representative.coneTypeUnsafe()) } } + is ConeDefinitelyNotNullType -> { + appendConeType(coneType.original) + return + } is ConeFlexibleType -> { appendConeType(coneType.lowerBound) return diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.kt b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.kt new file mode 100644 index 00000000000..04fde9e0fb9 --- /dev/null +++ b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.kt @@ -0,0 +1,5 @@ +// FULL_JDK + +fun foo(x: MutableMap>) { + x.merge("", listOf("")) { a, b -> a + b } +} diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.txt b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.txt new file mode 100644 index 00000000000..eb5a5df86ad --- /dev/null +++ b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.txt @@ -0,0 +1,7 @@ +FILE: mapMerge.kt + public final fun foo(x: R|kotlin/collections/MutableMap>|): R|kotlin/Unit| { + R|/x|.R|FakeOverride?|>|(String(), R|kotlin/collections/listOf|(String()), = merge@fun (a: R|ft, kotlin/collections/List?>!|, b: R|ft, kotlin/collections/List?>!|): R|ft, kotlin/collections/List?>!| { + ^ R|/a|.R|kotlin/collections/plus|(R|/b|) + } + ) + } 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 441c6bb4d39..df2c7ba2ac7 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -645,6 +645,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolveWithStdlib/j+k/MapEntry.kt"); } + @TestMetadata("mapMerge.kt") + public void testMapMerge() throws Exception { + runTest("compiler/fir/resolve/testData/resolveWithStdlib/j+k/mapMerge.kt"); + } + @TestMetadata("MyException.kt") public void testMyException() throws Exception { runTest("compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyException.kt");