Skip to content

Commit 62b6d01

Browse files
committed
[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).
1 parent 5985275 commit 62b6d01

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7207,6 +7207,21 @@ TypeVarBindingProducer::TypeVarBindingProducer(BindingSet &bindings)
72077207
return;
72087208
}
72097209

7210+
// Pack expansion type variable can only ever have one binding
7211+
// which is handled by \c resolvePackExpansion.
7212+
//
7213+
// There is no need to iterate over other bindings here because
7214+
// there is no use for contextual types (unlike closures that can
7215+
// propagate contextual information into the body).
7216+
if (TypeVar->getImpl().isPackExpansion()) {
7217+
for (const auto &entry : bindings.Defaults) {
7218+
auto *constraint = entry.second;
7219+
Bindings.push_back(getDefaultBinding(constraint));
7220+
}
7221+
7222+
return;
7223+
}
7224+
72107225
// A binding to `Any` which should always be considered as a last resort.
72117226
Optional<Binding> Any;
72127227

0 commit comments

Comments
 (0)