mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add Sugar for Variadics
We used to represent the interface type of variadic parameters directly with ArraySliceType. This was awfully convenient for the constraint solver since it could just canonicalize and open [T] to Array<$T> wherever it saw a variadic parameter. However, this both destroys the sugaring of T... and locks the representation to Array<T>. In the interest of generalizing this in the future, introduce VariadicSequenceType. For now, it canonicalizes to Array<T> just like the old representation. But, as you can guess, this is a new staging point for teaching the solver how to munge variadic generic type bindings. rdar://81628287
This commit is contained in:
@@ -2623,14 +2623,13 @@ namespace {
|
||||
|
||||
// Try to build the appropriate type for a variadic argument list of
|
||||
// the fresh element type. If that failed, just bail out.
|
||||
auto array = TypeChecker::getArraySliceType(expr->getLoc(), element);
|
||||
if (array->hasError()) return element;
|
||||
auto variadicSeq = VariadicSequenceType::get(element);
|
||||
|
||||
// Require the operand to be convertible to the array type.
|
||||
CS.addConstraint(ConstraintKind::Conversion,
|
||||
CS.getType(expr->getSubExpr()), array,
|
||||
CS.getType(expr->getSubExpr()), variadicSeq,
|
||||
CS.getConstraintLocator(expr));
|
||||
return array;
|
||||
return variadicSeq;
|
||||
}
|
||||
|
||||
Type visitDynamicTypeExpr(DynamicTypeExpr *expr) {
|
||||
|
||||
Reference in New Issue
Block a user