-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Add a type variable merging heuristic to addJoinConstraint #33296
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
…nstraint. This heuristic merges type variables for literal expressions of the same kind. This is valid because such type variables will have the same set of constraints on them, and must be bound to the same type.
Still need to update the test and also use |
da40585
to
5e7d7a9
Compare
@swift-ci please smoke test compiler performance |
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.
I feel like finding a representative (and equivalence class) for expressions and forming a join are two separate operations. Maybe this could be split into addJoinConstraint
which takes expressions and another overload of it which takes an iterator over type variables so one call call another when needed.
@xedin I don't think that, for this particular heuristic, joining types and merging representative type variables are two independent operations. Doing this in |
5e7d7a9
to
ad77613
Compare
@hborla Consider it from this perspective - join operator is responsive for establishing a particular relationship between a given set of type variables, its correctness is unrelated of properties of the type variables themselves. We are integrating heuristic into this method which is based on logic unrelated to the join operation itself - that all of the type variables of the same kind for an equivalence class - that by itself is true is certain situations e.g. if all of them are elements of a collection, arguments to a homogeneous call. I'm not sure if that's safe to do or does it just make it so any future use of |
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.
LGTM!
@swift-ci please test source compatibility |
@swift-ci please smoke test compiler performance |
Summary for master smoketestNo regressions above thresholds Debugdebug briefRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
debug detailedRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (16)
Releaserelease briefRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
release detailedRegressed (0)
Improved (0)
Unchanged (delta < 1.0% or delta < 100.0ms) (16)
|
an iterator range and a callback to get the type. This allows callers to lazily compute the input types to join rather than constructing an array first. The old addJoinConstraint is now a wrapper for this new overload.
af01773
to
cd44ca8
Compare
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please smoke test |
…ssage for each element whose type variable was merged in addJoinConstraint
@swift-ci please smoke test |
addJoinConstraint
that merges type variables for "atomic" literal expressions of the same kind. This is valid because such type variables will have the same set of constraints on them, and must be bound to the same type.addJoinConstraint
to take in an iterator range and a callback to get the input types/locators. This allows callers to lazily compute the inputs-to-join rather than construct an array beforehand. The oldaddJoinConstraint
is now a wrapper around this new overload.addJoinConstraint
to join array element types.Resolves: rdar://problem/66176314
Resolves: rdar://problem/30596744