-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-import missing implicits #141
Comments
Thanks for reporting! I think this is a great idea, I know @olafurpg was thinking about implementing it a while ago, but never actually went with it anywhere. |
Specifically for Scala 3, I made a naive attempt at implementing this some time ago. I think it's useful to re-surface this comment from smarter: https://github.com/scalameta/metals/pull/2536/files#r583848840 Contributing upstream to the reporting api in the compiler may be the way to go |
I started to do a bit of experimental implementation on this feature. (Importing the extension method in Scala3 is the first milestone). What we need to do for extension methods (in workspace) is:
I guess we can make However, the implicit conversion will be out of scope, in the following scenario, it's hard to tell which we need to import to use class RichInt(n: Int) {
def xxx = ???
}
implicit def toRichInt(x: Int) = new RichInt(x)
// another file
1.xxx |
|
For implicit classes, isn't the problem the same as with implicit conversions? Since you can potentially call |
Is your feature request related to a problem? Please describe.
It's currently not possible to auto-import implicit conversions/classes/parameteres.
Describe the solution you'd like
A quick fix that shows up when there are no implicits of the requested type found, but some are known to be available in the workspace. Also, when a selection is not available on a symbol but it would've been if there was an implicit conversion in scope, that could also be suggested.
Describe alternatives you've considered
Learning all implicits in the workspace by hand ;)
Additional context
IntelliJ IDEA just got an update that allows auto-importing implicits: https://blog.jetbrains.com/scala/2020/07/16/intellij-scala-plugin-2020-2-auto-import-for-implicits/
Search terms:
implicit, conversion, autoimport, import
The text was updated successfully, but these errors were encountered: