-
Notifications
You must be signed in to change notification settings - Fork 1k
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
In selector check, prefix of reference must match import qualifier #20894
base: main
Are you sure you want to change the base?
Conversation
Further tweaks forthcoming. |
@som-snytt how much work do you think it still requires? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first commit is a bit suspicious, and might be the cause of the CI failures.
The second commit looks good and might pass more easily if submitted as an independent PR.
I'll submit commit 2 separately, as I was about to do except it's one line. I'll follow up the fix for commit 1 after the American holiday. |
634fdb0
to
741473e
Compare
The previous test fails were because the new prefix check (in I'll clean up and also look for improvements. |
aa1526f
to
b6c0fb6
Compare
09d418a
to
75d4d24
Compare
Prefer context functions for brevity. Avoid intermediate collections.
75d4d24
to
0f4be8a
Compare
Rebased and split out commits for easier review. This includes adding the prefix type to This is the July commit and not the August rewrite, which fixes scope bugs by leveraging normal miniphase traversal and avoiding the special traverser; which allows putting Example extra test fixed in August:
As the comment reminds me, it incorrectly detects the superconstructor ref as resolved by the nested import. Also note that the inner wildcard is not ambiguous because both imports resolve to the same symbol. But a further improvement would be to warn that the inner import is, if not unused, then spurious. Edit: redrafting to add the August rewrites. |
Cherry-picked some old commits. As a reminder to future self, the mega phase was broken because CheckShadowing sees the nested X as shadowing.
The fix [sic] is to ignore everything nested because it ignores constructor-owned X and M. [Previous attempt had been to short-circuit transformDeep so CheckShadowing doesn't see subtrees of "other" trees.] The fix [also sic] to superclass context noted in previous comment is also novel: since all the "context" approximation is for the purpose of import tracking, it doesn't need to capture all the subtlety of a true super class constructor context (with class parameters in scope). Instead, just detect that a reference occurred in a parent tree, and then kick it upstairs in popScope. The mechanism for tracking The "inner traverser" is removed in favor of matching "other" trees and transforming their parts. I see there was some long discussion about this. The miniphase should be rewritten to leverage existing Context and Scope instead of custom structures. The problem of tracking just symbols is simpler (as in Scala 2), but for import tracking, it should use ImportContext etc. (The other PR for import tracking followed Scala 2 and let the compiler record lookups as they happen.) The motivation for proper contexts is so that a "lint framework" can rely on it, instead of custom traversals. For this phase, top-down may be more efficient than bubbling up references until they find a definition or import. Per context, a reference need be looked up only once, and then only if there are outstanding unused definitions or imports. |
|
Fixes #19657