-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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.
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) { |
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.
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) |
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.
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) { |
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.
Ditto about the trace.
val andType = trace(i"andType of scrut", gadts) { | ||
buildAndType(baseClasses) | ||
} | ||
constrainPatternType(pat, andType) |
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.
Ditto about andType
existing.
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. :) |
No description provided.