Is there an easy way to stop any stdlib functions ...
# getting-started
r
Is there an easy way to stop any stdlib functions from being imported automatically? I just got bit again when I accidentally used
value.toString()
instead of
value?.toString()
. I'm not a fan of
Any?.toString()
, and I'd like to just get rid of it locally if possible.
e
Copy code
import kotlin.toString as `-toString`
this should do what you want
r
Indeed, that does, though I meant for the whole project when I meant locally. It's as easy to forget that import as it is to forget to add the
?
, so I would like to set it once and never have it bother me again. If there isn't a way to remove it, is there a way to mark it as an error / warning?
e
1, there isn't a way. 2, you could probably write a #ktlint rule; outside of a framework like that, you'll have to do the work of figuring out type resolution yourself
r
Fair enough. Thanks
e
actually now that I think more, #detekt would work better than ktlint since that's the one with optional type resolution
👍 1