-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Gadt unification #5611
Gadt unification #5611
Conversation
This reverts commit 756cd0a.
Allow abstracting over what context is needed by ConstraintHandling.
if ((tycon2bounds.lo `eq` tycon2bounds.hi) && !tycon2bounds.isInstanceOf[MatchAlias]) | ||
if (followSuperType) recur(tp1, tp2.superType) |
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.
It reverted commit fills a hole in the subtype checker. What tests failed before we reverted it? It would be good to find a root cause for the failure.
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.
TypeSafeLambda
failed. Since this PR anyway leaves GADTs using HKTs unsound, I wanted to focus first on solving #5630, and then to come back to this problem.
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.
OK, agreed. Maybe make an issue so that it is not forgotten?
case tv: TypeVar => tv | ||
case inst => | ||
gadts.println(i"instantiated: $sym -> $inst") | ||
// this is wrong in general, but "correct" due to a subtype check in TypeComparer#narrowGadtBounds |
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.
More explanations needed.
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.
Fixed by inlining the code from TypeComparer#narrowGADTBounds
. Inlining it did not work previously, but whatever code was causing that must've changed along the way.
Overall this looks good. I have only minor comments. |
Cleaned up version of #5258.
Copying over relevant information:
This fixes all of the below:
For the time being, we mishandle injectivity and so we are unsound. See tests/run/gadt-injectivity-unsoundness.scala for a test showing a class cast exception. We will need to create an issue for this.
756cd0a was reverted because it was making the tests fail, and reverting it caused no test failures. I might bring it back later when working on injectivity.
At first glance, it might make sense to merge
GADTMap
state withTyperState
. However, it's not necessary (since it's possible to just keep a fresh copy ofGADTMap
as the "state") and it's not entirely obvious how to adapt already existing code. See #5258 (comment) for detailed reasoning. For the time being, I think it'd be best to leave the state where it is and refactor later if handling the GADT state becomes problematic.