KT-13689 Typealias constructor usage counts as original type usage for optimize imports
#KT-13689 Fixed (cherry picked from commit bde7e2b)
This commit is contained in:
committed by
Dmitry Petrov
parent
9d373fba67
commit
7d214c6e58
@@ -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
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ class ConvertAssertToIfWithThrowIntention : SelfTargetingIntention<KtCallExpress
|
||||
}
|
||||
|
||||
private fun replaceWithIfThenThrowExpression(original: KtCallExpression): KtIfExpression {
|
||||
val replacement = KtPsiFactory(original).createExpression("if (!true) { throw java.lang.AssertionError(\"\") }") as KtIfExpression
|
||||
val replacement = KtPsiFactory(original).createExpression("if (!true) { throw kotlin.AssertionError(\"\") }") as KtIfExpression
|
||||
val parent = original.parent
|
||||
return if (parent is KtDotQualifiedExpression)
|
||||
parent.replaced(replacement)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import kotlin.Any
|
||||
|
||||
fun foo(): Any {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(): Any {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
@@ -245,6 +245,12 @@ public class OptimizeImportsTestGenerated extends AbstractOptimizeImportsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeAliasUsage.kt")
|
||||
public void testTypeAliasUsage() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/optimizeImports/TypeAliasUsage.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("UnusedImports.kt")
|
||||
public void testUnusedImports() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/editor/optimizeImports/UnusedImports.kt");
|
||||
|
||||
Reference in New Issue
Block a user