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 bounds of match type cases #14645

Merged
merged 2 commits into from Mar 28, 2022

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Mar 8, 2022

No description provided.

@dwijnand dwijnand linked an issue Mar 8, 2022 that may be closed by this pull request
@dwijnand dwijnand force-pushed the match-type/reduce-tparam-bounds-pr branch from d67ceec to 0e578f1 Compare March 8, 2022 16:07
@dwijnand dwijnand force-pushed the match-type/reduce-tparam-bounds-pr branch from 0e578f1 to 3a00dc5 Compare March 8, 2022 16:25
@dwijnand dwijnand changed the title When assigning type cases, substitute any instances of type parameters for the applied arguments Fix bounds of match type cases Mar 8, 2022
@dwijnand dwijnand requested a review from smarter March 8, 2022 18:25
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

I don't have a full understanding of the match type logic but my gut reaction here is that this is a lot of code in TypeAssigner which is supposed to be mostly straightforward. Can we ensure these symbols have the correct info at the point they're created (both in typer and treeunpicker) instead?

@dwijnand
Copy link
Member Author

dwijnand commented Mar 8, 2022

I don't see how to do that. The loop is in typing the arg of the AppliedTypeTree (typedAppliedTypeTree) and the symbols are created in typing the bind (typedBind). In my example I need the symbol for A so I can use it as the upper bound of the symbol for X. But there's no restriction on the definition order, so I could be typing the binding for X before I've even got a symbol for A.

So unless you can see another way to pipe and order things, I propose we use the substitute mechanism to post-process them. There's seems to be a bunch of precedent for doing things very similarly to how I am, or at least to my eyes...

@dwijnand dwijnand marked this pull request as ready for review March 8, 2022 21:24
@dwijnand dwijnand requested a review from odersky March 8, 2022 21:24
@dwijnand
Copy link
Member Author

dwijnand commented Mar 8, 2022

cc also @odersky, in case he can recommend better ways or places to do this.

Copy link
Contributor

@OlivierBlanvillain OlivierBlanvillain left a comment

Choose a reason for hiding this comment

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

LGTM! I'm happy that we fix this at the source, in TypeAssigner.

@dwijnand dwijnand merged commit 441afc5 into scala:main Mar 28, 2022
@dwijnand dwijnand deleted the match-type/reduce-tparam-bounds-pr branch March 28, 2022 13:08
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
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.

Match type with bounds fails to reduce
4 participants