Skip to content

Rename on import is never wildcard #22712

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

Merged

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Mar 5, 2025

Forward port #22710

For a symbol referenced by an alternate name, there must be renaming selector in scope (because the code typechecks), and that import is necessarily higher precedence than a wildcard and will be preferred.

However, it's wrong unnecessary to track the wildcard as a candidate solution. The laborious conversion to terms is necessary because the name does not remember whether it was a rename (i.e., due to an OriginalName attachment). Note that if the name test is more expensive than the current cost, then this commit would be less efficient; a mantra of the refactor was to defer the cost of executing a test.

@som-snytt som-snytt marked this pull request as ready for review March 6, 2025 18:32
@Gedochao Gedochao requested review from sjrd and KacperFKorban March 7, 2025 09:08
Copy link
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

Missing test?

@som-snytt som-snytt force-pushed the port/issue/22692-rename-is-never-wildcard branch from 162a3f0 to f31a069 Compare March 7, 2025 15:18
@som-snytt
Copy link
Contributor Author

I assumed the rename tests in https://github.com/scala/scala3/blob/main/tests/warn/i15503a.scala cover it, but it doesn't hurt to add the new test code. The existing test is augmented and also behaves differently from the original commit.

This commit does not change correctness, and I did not instrument the internal behavior for testing.

@som-snytt som-snytt merged commit 977232c into scala:main Mar 7, 2025
29 checks passed
@som-snytt som-snytt deleted the port/issue/22692-rename-is-never-wildcard branch March 7, 2025 19:18
@WojciechMazur WojciechMazur added this to the 3.7.0 milestone Mar 11, 2025
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.

4 participants