Improve "optimize imports" behavior on default imports

Optimize imports to classes when there's an import of a type alias to
that class with the same name. This results in "java.lang.*" imports
being optimized in favor of the corresponding type aliases in "kotlin.*"
which are imported by default
This commit is contained in:
Alexander Udalov
2018-07-13 17:44:49 +02:00
parent ce34deb9af
commit f766b2c473
9 changed files with 87 additions and 2 deletions
@@ -0,0 +1,10 @@
import java.lang.IllegalArgumentException
import kotlin.run
fun main(args: Array<String>) {
run {
throw IllegalArgumentException()
}
}
fun type(): IllegalArgumentException? = null
@@ -0,0 +1,7 @@
fun main(args: Array<String>) {
run {
throw IllegalArgumentException()
}
}
fun type(): IllegalArgumentException? = null
@@ -0,0 +1,8 @@
Additional checking of reference Getter: IllegalArgumentException
Additional checking of reference KtSimpleNameReference: IllegalArgumentException
Additional checking of reference Getter: run
Additional checking of reference KtSimpleNameReference: run
Additional checking of reference KtInvokeFunctionReference: IllegalArgumentException()
Additional checking of reference KtInvokeFunctionReference: run {
throw IllegalArgumentException()
}
@@ -0,0 +1,5 @@
package dep1
class A
class B
@@ -0,0 +1,7 @@
package dep2
// Type alias with the same name
typealias A = dep1.A
// Type alias with a different name
typealias BBB = dep2.B
@@ -0,0 +1,9 @@
import dep1.A
import dep1.B
import dep2.*
fun test(
a: A,
b: B,
bbb: BBB
) {}
@@ -0,0 +1,9 @@
import dep1.A
import dep1.B
import dep2.BBB
fun test(
a: A,
b: B,
bbb: BBB
) {}