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

Avoid forcing ctors & parents which caused cycles #17086

Merged
merged 2 commits into from
Aug 11, 2024

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Mar 11, 2023

Fixes #15177

The current class completion eagerly completes the constructor before finishing. This means that any reference within the constructor that ends up referencing that class would fail as "cyclic" even though the actual classes aren't cyclic. With the change in #16664 "Disallow constructor params from appearing in parent types for soundness", I thought perhaps that was the motivation for the completion, so with that motivation going away we could fix this code. It turns out that DerivedFromParamTree perhaps was at the centre of this. Without changing that scheme, I allowed for the necessary indexing to occur on the constructor for successful compilation, deferring the rest of the constructor completion for later.

It seems this has impacted a number of users, it used to work in Scala 2, and there's nothing wrong with it compiling, so I think we find a way to make it.

@dwijnand dwijnand self-assigned this Mar 23, 2023
@dwijnand
Copy link
Member Author

Need to go back, see if we can make class completion defer completing the constructor, now that #16664 is in.

@dwijnand dwijnand changed the title Allow simple type args of parent types to back reference Avoid forcing ctors & parents which caused cycles Jun 11, 2024
@dwijnand dwijnand marked this pull request as ready for review June 11, 2024 13:03
@dwijnand dwijnand requested a review from odersky June 11, 2024 13:05
@dwijnand dwijnand assigned odersky and unassigned dwijnand Jun 11, 2024
@dwijnand dwijnand force-pushed the cyclic-namer branch 2 times, most recently from dfea49c to a4a87b0 Compare June 14, 2024 09:44
@dwijnand
Copy link
Member Author

Added comments to the changes and added detail to the PR description.

@dwijnand
Copy link
Member Author

dwijnand commented Aug 7, 2024

@odersky Can I do anything to assist in reviewing and merging this?

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

It's difficult for me to review this because the change set is large and the issues are very subtle. Would it be possible to split this in two commits? The first commit should only refactor things and move code around (it seems there's quite a bit of that). The second commit should then change the logic.

compiler/src/dotty/tools/dotc/core/TypeApplications.scala Outdated Show resolved Hide resolved
@dwijnand
Copy link
Member Author

dwijnand commented Aug 8, 2024

Yep absolutely.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

It's complicated, but i think I get it. Looks good to me!

@odersky odersky assigned dwijnand and unassigned odersky Aug 10, 2024
@dwijnand
Copy link
Member Author

Thank you Martin.

@dwijnand dwijnand merged commit c04e247 into scala:main Aug 11, 2024
28 checks passed
@dwijnand dwijnand deleted the cyclic-namer branch August 11, 2024 08:15
WojciechMazur added a commit that referenced this pull request Aug 28, 2024
…#21487)

Backports #17086 to the 3.5.2 branch.

PR submitted by the release tooling.
[skip ci]
@WojciechMazur WojciechMazur added this to the 3.5.2 milestone Oct 8, 2024
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.

Spurious 'type is not a member'
4 participants