# stdlib

Michal Klimczak

03/09/2023, 7:35 AM
I'm trying to use
, but it doesn't use all the imports. One of the imports is related to the expression used in ReplaceWith, the other is added for a top level extension function which would retrofit the old deprecated usage. But the other one is not automatically included by IDE, when replacing. Is that by design or am I encountering some bug?

Adam S

03/09/2023, 9:08 AM
Can you share some code to demonstrate what you've tried, what the result is, and what you'd expect?
my guess is that there's already an import with the same name, so IntelliJ won't replace it
Copy code
import a.b.c.OldFoo
import a.b.c.NewFoo

@Deprecated("", ReplaceWith("x.y.z.NewFoo(...)")
val x = OldFoo("blah")

val someOtherVar = NewFoo("asd")
results in
Copy code
import a.b.c.OldFoo
import a.b.c.NewFoo
// import x.y.z.NewFoo // can't add this import

val x = x.y.z.NewFoo("blah") // so must use the FQN

val someOtherVar = NewFoo("asd")

Michal Klimczak

03/09/2023, 10:06 AM
Sure thing. Take a look at this:
Copy code
package com.example.utils

    "oh well",
    ReplaceWith("FooNew", "com.example.utils.FooNew", ""),
class FooOld {
    fun bar() = Unit

class FooNew

fun = Unit
And then used like this
Copy code
package com.example.something

import com.example.utils.FooOld

fun something() = FooOld().bar()
It will import
, but will not import
I would expect it to use both imports, why ide tries to be smarter and choose the ones that it thinks are used

Adam S

03/09/2023, 10:16 AM
yeah, I wouldn't expect that behaviour either, good find. I say you should make an issue on YouTrack.
👍 1