-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ConstraintSystem] Add BindingProducer
base type
#19132
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
Add all of the important information to the `TypeBinding` which covers both type variable and disjunction choices.
…nding` * Extract logic for attempting individual choices into `solveForDisjunctionChoice` * Remove all of the unnecessary information from `DisjunctionChoice` * Convert auxiliary logic to operate on `TypeBinding` instead of `DisjunctionChoice`
lib/Sema/ConstraintSystem.h
Outdated
|
||
return TypeVariableBinding(TypeVar, Bindings[Index++]); | ||
unsigned currIndex = Index++; | ||
return llvm::make_unique<TypeVariableBinding>(currIndex, TypeVar, |
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.
@rudkx For some reason solver would just crash when I tried to do new (CS.getAllocator())
, I also tried to call
void *mem = CS.getAllocator().Allocate(sizeof(TypeVariableBinding), alignof(TypeVariableBinding));
auto *binding = new (mem) ...
which didn't help either... It seems to work fine with new
though... Any ideas?
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.
Does it crash when allocating, or later?
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.
Later, when it’s trying to access fields I think
Introduce a base `BindingProducer` type which can produce bindings for both type variables and disjunctions.
c2d1012
to
2acfff0
Compare
@rudkx I have changed the interface of the |
lib/Sema/ConstraintSystem.h
Outdated
/// Position of this binding in the chain. | ||
unsigned getIndex() const { return Index; } | ||
|
||
virtual bool isDisabled() const { return false; } |
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.
Actually let me try to convert this into flags of the binding, so I don't have to create so many virtual methods...
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.
Okay, all done!
@swift-ci please test |
Build failed |
Build failed |
If nobody objects I'm going to merge tonight, since this is mostly NFC. |
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 only had a chance to do a quick look, but seems okay.
@swift-ci please ASAN test |
Introduce a base
BindingProducer
type which can produce bindingsfor both type variables and disjunctions.
It required some cleanup in the solver:
TypeBinding
such asgetIndex
,isDisabled
etc.solveForDisjunctionChoice
DisjunctionChoice
TypeBinding
instead ofDisjunctionChoice