Skip to content

Commit e7bcf37

Browse files
committed
[ConstraintSystem] Implement constraint generation and solution application for
PackElementExpr.
1 parent 4529d4f commit e7bcf37

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3830,7 +3830,7 @@ namespace {
38303830
}
38313831

38323832
Expr *visitPackElementExpr(PackElementExpr *expr) {
3833-
llvm_unreachable("not implemented for PackElementExpr");
3833+
return simplifyExprType(expr);
38343834
}
38353835

38363836
Expr *visitDynamicTypeExpr(DynamicTypeExpr *expr) {

lib/Sema/CSGen.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2993,7 +2993,19 @@ namespace {
29932993
}
29942994

29952995
Type visitPackElementExpr(PackElementExpr *expr) {
2996-
llvm_unreachable("not implemented for PackElementExpr");
2996+
auto packType = CS.getType(expr->getPackRefExpr());
2997+
auto *elementType =
2998+
CS.createTypeVariable(CS.getConstraintLocator(expr),
2999+
TVO_CanBindToHole);
3000+
auto *elementEnv = PackElementEnvironments.back();
3001+
auto *elementLoc = CS.getConstraintLocator(
3002+
expr, LocatorPathElt::OpenedPackElement(elementEnv));
3003+
3004+
// The type of a PackElementExpr is the opened pack element archetype
3005+
// of the pack reference.
3006+
CS.addConstraint(ConstraintKind::PackElementOf, elementType, packType,
3007+
elementLoc);
3008+
return elementType;
29973009
}
29983010

29993011
Type visitDynamicTypeExpr(DynamicTypeExpr *expr) {

0 commit comments

Comments
 (0)