Skip to content
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

fix: generate auto-imports for more pattern completions #7292

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

harpocrates
Copy link
Contributor

This tweaks the case-completion logic to always take auto-imports into account. The auto-import logic was present for known direct subclasses, but not for some other cases. Now, they all get handled uniformly.

The only hair in the soup is that extra work needs to go in to

 def myList: List[Int]
 myList match {
   case N@@   // want `case Nil =>`, not `case immutable.Nil =>`
 }

Reason here is that the Nil variant is completing with scala.collection.immutable.Nil, while only scala.Nil is in scope. The scala.* package re-exports are narrowly worked around since they probably would occur frequently.

This tweaks the case-completion logic to always take auto-imports into
account. The auto-import logic was present for known direct subclasses,
but not for some other cases. Now, they all get handled uniformly.

The only hair in the soup is that extra work needs to go in to

   def myList: List[Int]
   myList match {
     case N@@   // want `case Nil =>`, not `case immutable.Nil =>`
   }

Reason here is that the `Nil` variant is completing with
`scala.collection.immutable.Nil`, while only `scala.Nil` is in scope.
The `scala.*` package re-exports are narrowly worked around since they
probably would occur frequently.
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! You also fixed a case for Scala 2.11, so I pushed a small tweak. Thanks!

@tgodzik tgodzik merged commit 9a03961 into scalameta:main Mar 11, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants