[ConstraintSystem] Form a special one type binding set for pack expansion variables

Pack expansion type variable can only ever have one binding
which is handled by \c resolvePackExpansion.

There is no need to iterate over other bindings here because
there is no use for contextual types (unlike closures that can
propagate contextual information into the body).
This commit is contained in:
Pavel Yaskevich
2023-04-12 16:22:45 -07:00
committed by Pavel Yaskevich
parent 5985275e6c
commit 62b6d010a1

View File

@@ -7207,6 +7207,21 @@ TypeVarBindingProducer::TypeVarBindingProducer(BindingSet &bindings)
return;
}
// Pack expansion type variable can only ever have one binding
// which is handled by \c resolvePackExpansion.
//
// There is no need to iterate over other bindings here because
// there is no use for contextual types (unlike closures that can
// propagate contextual information into the body).
if (TypeVar->getImpl().isPackExpansion()) {
for (const auto &entry : bindings.Defaults) {
auto *constraint = entry.second;
Bindings.push_back(getDefaultBinding(constraint));
}
return;
}
// A binding to `Any` which should always be considered as a last resort.
Optional<Binding> Any;