Reputation: 30723
Is there a way to suppress (e.g., via a commnad line flag passed to the compiler) Kotlin's default import of multiple packages? or - alternatively - to be selective about it?
Upvotes: 1
Views: 192
Reputation: 6569
This is easy, just use your alternative to replace it by using as
, and the default import will be replaced by your one.
Here's a simple example, if you want to use java.lang.String
instead of kotlin.String
, although it's not recommended, this is just an example.
import java.lang.String as String
// here, String is not `kotlin.String`.
private fun main(vararg args: String) {
}
BTW there's a trick about refactoring, like if you want to replace all Any
used in a file with java.lang.Object
, put this after the package declaration:
import java.lang.Object as Any
And the implicit import to Any
is suppressed and superseded by Object
.
Upvotes: 2