Skip to content

Change GADT constrainer to consider all parents of the scrutinee type when upcasting it #11521

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 3 commits into from
Mar 15, 2021

Conversation

Linyxus
Copy link
Contributor

@Linyxus Linyxus commented Feb 24, 2021

No description provided.

Copy link
Contributor

@abgruszecki abgruszecki left a comment

Choose a reason for hiding this comment

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

Good news, we can merge this PR in time for 3.0.0. Some tweaks would be nice, and then it's good to go!

scrut.firstParent
// consider all parents
val parents = scrut.parents
val andType = trace(i"andType of scrut", gadts) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This trace doesn't seem overall very useful, could you remove it?

val andType = trace(i"andType of scrut", gadts) {
buildAndType(parents)
}
constrainPatternType(pat, andType)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if andType exists, like in case _ below?

case _ => NoType
val allSyms = allParentsSharedWithPat(tycon, tycon.symbol.asClass)
val baseClasses = allSyms map scrut.baseType
val andType = trace(i"andType of scrut", gadts) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto about the trace.

val andType = trace(i"andType of scrut", gadts) {
buildAndType(baseClasses)
}
constrainPatternType(pat, andType)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto about andType existing.

@Linyxus
Copy link
Contributor Author

Linyxus commented Mar 12, 2021

Thank you for your review! I have removed unnecessary traces and added the existence checking. It's really good that we can include this feature in 3.0.0. :)

@abgruszecki abgruszecki merged commit 96bc3ff into scala:master Mar 15, 2021
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 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.

3 participants