-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Improve handling of types in constraint system. #6583
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
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please smoke test |
These places where we're calling back into the |
Yes it's possible a few of these should be moved into the constraint system. I did that with one or two functions in a previous commit. I looked at callWitness and it appeared to be used from other places outside of CSApply so I didn't look at moving it in. There are a few other places where we are currently writing types back, but I did that somewhat defensively at the moment to get closer to something that works. I intend on going back and removing ones that I suspect aren't actually needed (e.g. typeCheckExpressionShallow generally only looks at the untyped top-level node so perhaps it's not needed). It's difficult to do that as we're still writing the types in ConstraintSystem::setType(). I may be able to determine that today before actually merging any of this in. |
For something like Not that we have to do the above before merging this excellent PR; I'm thinking about the trajectory here. |
Okay I found a pile of new work I had missed originally where we pass Expr* into functions in Expr.cpp that read and write types, so I'm going to use this as a checkpoint and then address those issues. It looks like at least some of that functionality is only used from the constraint system and should just be moved there, and other pieces can probably be addressed in other ways. I think I'm going to try to encapsulate as much of the cruft here (by cruft I mean reading/writing types back and forth) into some entry points in ConstraintSystem that do the calls into the type checker so that there is one place it's happening rather than N. |
Several fixes in order to make handling of types more consistent. In particular: - Expression types used within the constraint system itself always use the type map. - Prior to calling out to any TypeChecker functions, the types are written back into the expression tree. After the call, the types are read back into the constraint system type map. - Some calls to directly set types on the expressions are reintroduced in places they make sense (e.g. when building up new expressions that are then passed to typeCheckExpressionShallow). ConstraintSystem::setType() is still setting the type on the expression nodes at the moment, because there is still some incorrect handling of types that I need to track down (in particular some issues related to closures do not appear to be handled correctly). Similarly, when we cache the types in the constraint system map, we are not clearing them from the expression tree yet. The diagnostics have not been updated at all to use the types from the constraint system where appropriate, and that will need to happen as well before we can remove the write from ConstraintSystem::setType() into the expression and enable the clearing of the expression tree type when we cache it in the constraint system.
@swift-ci Please smoke test and merge |
@swift-ci Please smoke test |
Several fixes in order to make handling of types more consistent.
In particular:
the type map.
written back into the expression tree. After the call, the types are
read back into the constraint system type map and cleared from the
expression tree.
in places they make sense (e.g. when building up new expressions that
are then passed to typeCheckExpressionShallow).
ConstraintSystem::setType() is still setting the type on the expression
nodes at the moment, because there is still some incorrect handling of
types that I need to track down (in particular some issues related to
closures do not appear to be handled correctly).
Also, the diagnostics have not been updated at all to use the types from
the constraint system where appropriate.