mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #40587 from CodaFi/substitute-teacher
Initial Semantics for Variadic Generics
This commit is contained in:
@@ -1602,11 +1602,12 @@ namespace {
|
||||
if (specializations.size() > typeVars.size()) {
|
||||
de.diagnose(expr->getSubExpr()->getLoc(),
|
||||
diag::type_parameter_count_mismatch,
|
||||
bgt->getDecl()->getName(),
|
||||
typeVars.size(), specializations.size(),
|
||||
false)
|
||||
.highlight(SourceRange(expr->getLAngleLoc(),
|
||||
expr->getRAngleLoc()));
|
||||
bgt->getDecl()->getName(), typeVars.size(),
|
||||
specializations.size(),
|
||||
/*too many arguments*/ false,
|
||||
/*type sequence?*/ false)
|
||||
.highlight(
|
||||
SourceRange(expr->getLAngleLoc(), expr->getRAngleLoc()));
|
||||
de.diagnose(bgt->getDecl(), diag::kind_declname_declared_here,
|
||||
DescriptiveDeclKind::GenericType,
|
||||
bgt->getDecl()->getName());
|
||||
@@ -1717,6 +1718,18 @@ namespace {
|
||||
return TupleType::get(elements, CS.getASTContext());
|
||||
}
|
||||
|
||||
Type visitPackExpr(PackExpr *expr) {
|
||||
// The type of a pack expression is simply a pack of the types of
|
||||
// its subexpressions.
|
||||
SmallVector<Type, 4> elements;
|
||||
elements.reserve(expr->getNumElements());
|
||||
for (unsigned i = 0, n = expr->getNumElements(); i != n; ++i) {
|
||||
elements.emplace_back(CS.getType(expr->getElement(i)));
|
||||
}
|
||||
|
||||
return PackType::get(CS.getASTContext(), elements);
|
||||
}
|
||||
|
||||
Type visitSubscriptExpr(SubscriptExpr *expr) {
|
||||
ValueDecl *decl = nullptr;
|
||||
if (expr->hasDecl()) {
|
||||
@@ -2764,7 +2777,7 @@ namespace {
|
||||
|
||||
CS.addConstraint(ConstraintKind::ApplicableFunction,
|
||||
FunctionType::get(params, resultType, extInfo),
|
||||
CS.getType(expr->getFn()),
|
||||
CS.getType(fnExpr),
|
||||
CS.getConstraintLocator(expr, ConstraintLocator::ApplyFunction));
|
||||
|
||||
// If we ended up resolving the result type variable to a concrete type,
|
||||
|
||||
Reference in New Issue
Block a user