From 403801b0b3aa15b8ca5748434115998b7db39581 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Wed, 20 Mar 2019 22:59:10 +0700 Subject: [PATCH] Fix exception when add import #KT-30524 Fixed --- .../jetbrains/kotlin/descriptors/Visibilities.java | 2 +- .../addImport/ConflictingLocalRef.dependency.kt | 10 ++++++++++ idea/testData/addImport/ConflictingLocalRef.kt | 13 +++++++++++++ .../testData/addImport/ConflictingLocalRef.kt.after | 8 ++++++++ .../kotlin/addImport/AddImportTestGenerated.java | 5 +++++ 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 idea/testData/addImport/ConflictingLocalRef.dependency.kt create mode 100644 idea/testData/addImport/ConflictingLocalRef.kt create mode 100644 idea/testData/addImport/ConflictingLocalRef.kt.after diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/Visibilities.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/Visibilities.java index 6db5f39d570..1a4d05d319e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/Visibilities.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/Visibilities.java @@ -236,7 +236,7 @@ public class Visibilities { public static final Visibility LOCAL = new Visibility("local", false) { @Override public boolean mustCheckInImports() { - throw new IllegalStateException("This method shouldn't be invoked for LOCAL visibility"); + return true; } @Override diff --git a/idea/testData/addImport/ConflictingLocalRef.dependency.kt b/idea/testData/addImport/ConflictingLocalRef.dependency.kt new file mode 100644 index 00000000000..26c0557053e --- /dev/null +++ b/idea/testData/addImport/ConflictingLocalRef.dependency.kt @@ -0,0 +1,10 @@ +package test + +fun a1() {} +fun a2() {} +fun a3() {} +fun a4() {} +fun a5() {} +fun a6() {} +fun a7() {} +val kotlinType = "ds" \ No newline at end of file diff --git a/idea/testData/addImport/ConflictingLocalRef.kt b/idea/testData/addImport/ConflictingLocalRef.kt new file mode 100644 index 00000000000..3b8becf1a3c --- /dev/null +++ b/idea/testData/addImport/ConflictingLocalRef.kt @@ -0,0 +1,13 @@ +// IMPORT: test.a7 +import test.a1 +import test.a2 +import test.a3 +import test.a4 +import test.a5 +import test.a6 + +fun test() { + val kotlinType = "" + kotlinType + a7() +} \ No newline at end of file diff --git a/idea/testData/addImport/ConflictingLocalRef.kt.after b/idea/testData/addImport/ConflictingLocalRef.kt.after new file mode 100644 index 00000000000..d1916889cad --- /dev/null +++ b/idea/testData/addImport/ConflictingLocalRef.kt.after @@ -0,0 +1,8 @@ +// IMPORT: test.a7 +import test.* + +fun test() { + val kotlinType = "" + kotlinType + a7() +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/addImport/AddImportTestGenerated.java b/idea/tests/org/jetbrains/kotlin/addImport/AddImportTestGenerated.java index 669c591e14e..9ab433c5781 100644 --- a/idea/tests/org/jetbrains/kotlin/addImport/AddImportTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/addImport/AddImportTestGenerated.java @@ -59,6 +59,11 @@ public class AddImportTestGenerated extends AbstractAddImportTest { runTest("idea/testData/addImport/CommentsNoPackageDirective.kt"); } + @TestMetadata("ConflictingLocalRef.kt") + public void testConflictingLocalRef() throws Exception { + runTest("idea/testData/addImport/ConflictingLocalRef.kt"); + } + @TestMetadata("ConflictingNameAppearsAndHasUsage1.kt") public void testConflictingNameAppearsAndHasUsage1() throws Exception { runTest("idea/testData/addImport/ConflictingNameAppearsAndHasUsage1.kt");