mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] Introduce UnresolvedMemberChainResultExpr
Introduce a new expression type for representing the result of an unresolved member chain. Use this expression type instead of an implicit ParenExpr for giving unresolved member chain result types representation in the AST during type checking.
This commit is contained in:
@@ -3259,21 +3259,22 @@ namespace {
|
||||
}
|
||||
|
||||
Expr *visitParenExpr(ParenExpr *expr) {
|
||||
// If this was an implicit ParenExpr inserted to give an unresolved member
|
||||
// chain result type visibility in the AST (see
|
||||
// ConstraintWalker::walkToExprPost), remove it from the AST now that we
|
||||
// have a solution.
|
||||
if (expr->isUnresolvedMemberChainPlaceholder()) {
|
||||
auto *subExpr = expr->getSubExpr();
|
||||
auto type = simplifyType(cs.getType(expr));
|
||||
subExpr = coerceToType(subExpr, type, cs.getConstraintLocator(subExpr));
|
||||
cs.setType(subExpr, type);
|
||||
return subExpr;
|
||||
}
|
||||
|
||||
return simplifyExprType(expr);
|
||||
}
|
||||
|
||||
Expr *visitUnresolvedMemberChainResultExpr(
|
||||
UnresolvedMemberChainResultExpr *expr) {
|
||||
// Since this expression only exists to give the result type of an
|
||||
// unresolved member chain visibility in the AST, remove it from the AST
|
||||
// now that we have a solution and coerce the subexpr to the resulting
|
||||
// type.
|
||||
auto *subExpr = expr->getSubExpr();
|
||||
auto type = simplifyType(cs.getType(expr));
|
||||
subExpr = coerceToType(subExpr, type, cs.getConstraintLocator(subExpr));
|
||||
cs.setType(subExpr, type);
|
||||
return subExpr;
|
||||
}
|
||||
|
||||
Expr *visitTupleExpr(TupleExpr *expr) {
|
||||
return simplifyExprType(expr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user