From 30c7f633bdd94454a8eeb94c667014d0d9d90ea4 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Mon, 11 Sep 2017 22:24:57 +0300 Subject: [PATCH] KJS: don't load declarations marked by PlatformDependent annotation #KT-17450 Fixed --- .../diagnostics/testsWithJsStdLib/platformDependent.kt | 5 +++++ .../diagnostics/testsWithJsStdLib/platformDependent.txt | 3 +++ .../checkers/DiagnosticsTestWithJsStdLibGenerated.java | 6 ++++++ .../js/kotlinJavascriptPackageFragmentProvider.kt | 4 +++- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.kt create mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.txt diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.kt b/compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.kt new file mode 100644 index 00000000000..7a5381d24c7 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.kt @@ -0,0 +1,5 @@ +fun test(m: Map, mm: MutableMap) { + m.getOrDefault("2", 1) + mm.getOrDefault(1, "2") + mm.remove(1, "2") +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.txt b/compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.txt new file mode 100644 index 00000000000..afa0f36e9fa --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.txt @@ -0,0 +1,3 @@ +package + +public fun test(/*0*/ m: kotlin.collections.Map, /*1*/ mm: kotlin.collections.MutableMap): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java index f08e5c14dd9..8a92d12fac9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java @@ -54,6 +54,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes doTest(fileName); } + @TestMetadata("platformDependent.kt") + public void testPlatformDependent() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/platformDependent.kt"); + doTest(fileName); + } + @TestMetadata("runtimeAnnotations.kt") public void testRuntimeAnnotations() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/runtimeAnnotations.kt"); diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/kotlinJavascriptPackageFragmentProvider.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/kotlinJavascriptPackageFragmentProvider.kt index b950344cb27..869927bfdd8 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/kotlinJavascriptPackageFragmentProvider.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/kotlinJavascriptPackageFragmentProvider.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.NotFoundClasses import org.jetbrains.kotlin.descriptors.PackageFragmentProvider import org.jetbrains.kotlin.descriptors.PackageFragmentProviderImpl +import org.jetbrains.kotlin.descriptors.deserialization.PlatformDependentDeclarationFilter import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.serialization.ProtoBuf @@ -56,7 +57,8 @@ fun createKotlinJavascriptPackageFragmentProvider( lookupTracker, DynamicTypeDeserializer, emptyList(), - notFoundClasses + notFoundClasses, + platformDependentDeclarationFilter = PlatformDependentDeclarationFilter.NoPlatformDependent ) for (packageFragment in packageFragments) {