From 7d214c6e5888ff462f59e9e13d8b9582361a5367 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 14 Sep 2016 22:26:22 +0300 Subject: [PATCH] KT-13689 Typealias constructor usage counts as original type usage for optimize imports #KT-13689 Fixed (cherry picked from commit bde7e2b) --- .../src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt | 2 ++ .../idea/intentions/ConvertAssertToIfWithThrowIntention.kt | 2 +- idea/testData/editor/optimizeImports/TypeAliasUsage.kt | 5 +++++ .../testData/editor/optimizeImports/TypeAliasUsage.kt.after | 3 +++ .../kotlin/idea/imports/OptimizeImportsTestGenerated.java | 6 ++++++ 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 idea/testData/editor/optimizeImports/TypeAliasUsage.kt create mode 100644 idea/testData/editor/optimizeImports/TypeAliasUsage.kt.after diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt index ff07937c713..cd82ba1aece 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.ClassKind.* import org.jetbrains.kotlin.descriptors.annotations.Annotated import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention +import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -40,6 +41,7 @@ fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = companion fun DeclarationDescriptor.getImportableDescriptor(): DeclarationDescriptor { return when { + this is TypeAliasConstructorDescriptor -> typeAliasDescriptor this is ConstructorDescriptor -> containingDeclaration this is PropertyAccessorDescriptor -> correspondingProperty else -> this diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt index be0460cb041..fd04fc0ade5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertAssertToIfWithThrowIntention.kt @@ -114,7 +114,7 @@ class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention