Skip to content

Check only stable qual for import prefix #22633

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
merged 1 commit into from
Feb 25, 2025

Conversation

som-snytt
Copy link
Contributor

Selection from a tree with synthetic span looks like a rewrite from imported symbol, but only check that if the qualifier is stable.

In the example, it was an implicit class (EitherOps), which in turn induced many costly, unnecessary type comparisons.

The test sample code is not yet minimized, so it is just for demonstration purposes. Since the symptom is a performance regression, there is no trivial test that demonstrates it was doing something wrong, as well as doing it slowly.

Locally, -verbose reports

[typer  in 5991ms]
[checkUnusedPostTyper  in 337ms]

Fixes #22629

@som-snytt som-snytt marked this pull request as ready for review February 21, 2025 06:17
@Gedochao Gedochao requested a review from sjrd February 21, 2025 06:38
Copy link
Member

Choose a reason for hiding this comment

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

Is it intended that this file has no indentation whatsoever?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ingested the generated file as-is. I did try a version limited to 3 type params, but that doesn't show much.

Probably I will drop the large test source, but is there anything useful to add as a test? A "performance" test could generate it, etc. Or maybe it's no big deal to leave as it is for now. It's a few kb that will never leave the repo.

@som-snytt som-snytt force-pushed the issue/22629-unused-performance branch from b95bb20 to 77af110 Compare February 24, 2025 16:35
@som-snytt
Copy link
Contributor Author

som-snytt commented Feb 24, 2025

Minimization doesn't use the EitherOps extension after all. It relies on -Yno-deep-subtypes to throw if we're doing the suspicious comparison.

I was prepared to generate the large source in CompilationTests and manually compileFile.

@som-snytt som-snytt force-pushed the issue/22629-unused-performance branch from 77af110 to 5429dfa Compare February 25, 2025 00:17
@sjrd sjrd merged commit 7995e9b into scala:main Feb 25, 2025
29 checks passed
@som-snytt som-snytt deleted the issue/22629-unused-performance branch February 25, 2025 12:08
sjrd added a commit that referenced this pull request Mar 4, 2025
Follow-up to #22633 which restricts
import prefixes to stable prefixes.

This commit further excludes `this` and `super`; these are arbitrary
synthetic expressions introduced by macros.

Noticed at
#22690 (comment)
which now warns correctly.

Requires a unit test.

Fixes #22690
@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.

Severe performance regression in neotypes/neotypes
3 participants