Skip to content

Commit 74f8960

Browse files
slavapestovxedin
authored andcommitted
Sema: Remove OneWayExpr and Builtin.one_way
1 parent 192bb33 commit 74f8960

11 files changed

+1
-199
lines changed

include/swift/AST/Expr.h

-27
Original file line numberDiff line numberDiff line change
@@ -6413,33 +6413,6 @@ class SingleValueStmtExpr : public Expr {
64136413
}
64146414
};
64156415

6416-
/// Expression node that effects a "one-way" constraint in
6417-
/// the constraint system, allowing type information to flow from the
6418-
/// subexpression outward but not the other way.
6419-
///
6420-
/// One-way expressions are generally implicit and synthetic, introduced by
6421-
/// the type checker. However, there is a built-in expression of the
6422-
/// form \c Builtin.one_way(x) that forms a one-way constraint coming out
6423-
/// of expression `x` that can be used for testing purposes.
6424-
class OneWayExpr : public Expr {
6425-
Expr *SubExpr;
6426-
6427-
public:
6428-
/// Construct an implicit one-way expression from the given subexpression.
6429-
OneWayExpr(Expr *subExpr)
6430-
: Expr(ExprKind::OneWay, /*isImplicit=*/true), SubExpr(subExpr) { }
6431-
6432-
SourceLoc getLoc() const { return SubExpr->getLoc(); }
6433-
SourceRange getSourceRange() const { return SubExpr->getSourceRange(); }
6434-
6435-
Expr *getSubExpr() const { return SubExpr; }
6436-
void setSubExpr(Expr *subExpr) { SubExpr = subExpr; }
6437-
6438-
static bool classof(const Expr *E) {
6439-
return E->getKind() == ExprKind::OneWay;
6440-
}
6441-
};
6442-
64436416
class TypeJoinExpr final : public Expr,
64446417
private llvm::TrailingObjects<TypeJoinExpr, Expr *> {
64456418
friend TrailingObjects;

include/swift/AST/ExprNodes.def

-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ EXPR(KeyPath, Expr)
214214
EXPR(CurrentContextIsolation, Expr)
215215
EXPR(SingleValueStmt, Expr)
216216
UNCHECKED_EXPR(KeyPathDot, Expr)
217-
UNCHECKED_EXPR(OneWay, Expr)
218217
EXPR(Tap, Expr)
219218
UNCHECKED_EXPR(TypeJoin, Expr)
220219
EXPR(MacroExpansion, Expr)

lib/AST/ASTDumper.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -3339,12 +3339,6 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, StringRef>,
33393339
printFoot();
33403340
}
33413341

3342-
void visitOneWayExpr(OneWayExpr *E, StringRef label) {
3343-
printCommon(E, "one_way_expr", label);
3344-
printRec(E->getSubExpr());
3345-
printFoot();
3346-
}
3347-
33483342
void visitTapExpr(TapExpr *E, StringRef label) {
33493343
printCommon(E, "tap_expr", label);
33503344
printDeclRefField(E->getVar(), "var");

lib/AST/ASTPrinter.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -4884,10 +4884,6 @@ void PrintAST::visitCoerceExpr(CoerceExpr *expr) {
48844884
printType(expr->getCastType());
48854885
}
48864886

4887-
void PrintAST::visitOneWayExpr(OneWayExpr *expr) {
4888-
llvm_unreachable("Not representable in source code");
4889-
}
4890-
48914887
void PrintAST::printClosure(AbstractClosureExpr *closure, CaptureListExpr *captureList) {
48924888

48934889
}

lib/AST/ASTWalker.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -1332,18 +1332,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
13321332
return E;
13331333
}
13341334

1335-
Expr *visitOneWayExpr(OneWayExpr *E) {
1336-
if (auto oldSubExpr = E->getSubExpr()) {
1337-
if (auto subExpr = doIt(oldSubExpr)) {
1338-
E->setSubExpr(subExpr);
1339-
} else {
1340-
return nullptr;
1341-
}
1342-
}
1343-
1344-
return E;
1345-
}
1346-
13471335
Expr *visitTapExpr(TapExpr *E) {
13481336
if (auto oldSubExpr = E->getSubExpr()) {
13491337
if (auto subExpr = doIt(oldSubExpr)) {

lib/AST/Expr.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ ConcreteDeclRef Expr::getReferencedDecl(bool stopAtParenExpr) const {
461461
NO_REFERENCE(KeyPath);
462462
NO_REFERENCE(KeyPathDot);
463463
PASS_THROUGH_REFERENCE(CurrentContextIsolation, getActor);
464-
PASS_THROUGH_REFERENCE(OneWay, getSubExpr);
465464
NO_REFERENCE(Tap);
466465
NO_REFERENCE(TypeJoin);
467466
SIMPLE_REFERENCE(MacroExpansion, getMacroRef);
@@ -662,7 +661,6 @@ bool Expr::canAppendPostfixExpression(bool appendingPostfixOperator) const {
662661
case ExprKind::Error:
663662
case ExprKind::CodeCompletion:
664663
case ExprKind::LazyInitializer:
665-
case ExprKind::OneWay:
666664
return false;
667665

668666
case ExprKind::NilLiteral:
@@ -1037,7 +1035,6 @@ bool Expr::isValidParentOfTypeExpr(Expr *typeExpr) const {
10371035
case ExprKind::ObjCSelector:
10381036
case ExprKind::KeyPath:
10391037
case ExprKind::KeyPathDot:
1040-
case ExprKind::OneWay:
10411038
case ExprKind::Tap:
10421039
case ExprKind::SingleValueStmt:
10431040
case ExprKind::TypeJoin:

lib/Sema/CSApply.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -5469,11 +5469,6 @@ namespace {
54695469
llvm_unreachable("Handled by the walker directly");
54705470
}
54715471

5472-
Expr *visitOneWayExpr(OneWayExpr *E) {
5473-
auto type = simplifyType(cs.getType(E));
5474-
return coerceToType(E->getSubExpr(), type, cs.getConstraintLocator(E));
5475-
}
5476-
54775472
Expr *visitTapExpr(TapExpr *E) {
54785473
auto type = simplifyType(cs.getType(E));
54795474

lib/Sema/CSGen.cpp

+1-17
Original file line numberDiff line numberDiff line change
@@ -3163,14 +3163,6 @@ namespace {
31633163
llvm_unreachable("Handled by the walker directly");
31643164
}
31653165

3166-
Type visitOneWayExpr(OneWayExpr *expr) {
3167-
auto locator = CS.getConstraintLocator(expr);
3168-
auto resultTypeVar = CS.createTypeVariable(locator, 0);
3169-
CS.addConstraint(ConstraintKind::OneWayEqual, resultTypeVar,
3170-
CS.getType(expr->getSubExpr()), locator);
3171-
return resultTypeVar;
3172-
}
3173-
31743166
Type visitTapExpr(TapExpr *expr) {
31753167
DeclContext *varDC = expr->getVar()->getDeclContext();
31763168
ASSERT(varDC != nullptr);
@@ -3333,7 +3325,6 @@ namespace {
33333325
JoinInout,
33343326
JoinMeta,
33353327
JoinNonexistent,
3336-
OneWay,
33373328
};
33383329

33393330
static TypeOperation getTypeOperation(UnresolvedDotExpr *UDE,
@@ -3347,7 +3338,6 @@ namespace {
33473338

33483339
return llvm::StringSwitch<TypeOperation>(
33493340
UDE->getName().getBaseIdentifier().str())
3350-
.Case("one_way", TypeOperation::OneWay)
33513341
.Case("type_join", TypeOperation::Join)
33523342
.Case("type_join_inout", TypeOperation::JoinInout)
33533343
.Case("type_join_meta", TypeOperation::JoinMeta)
@@ -3361,7 +3351,6 @@ namespace {
33613351

33623352
switch (op) {
33633353
case TypeOperation::None:
3364-
case TypeOperation::OneWay:
33653354
llvm_unreachable(
33663355
"We should have a valid type operation at this point!");
33673356

@@ -3558,12 +3547,7 @@ namespace {
35583547
auto typeOperation =
35593548
ConstraintGenerator::getTypeOperation(UDE, CS.getASTContext());
35603549

3561-
if (typeOperation == ConstraintGenerator::TypeOperation::OneWay) {
3562-
// For a one-way constraint, create the OneWayExpr node.
3563-
auto *unaryArg = apply->getArgs()->getUnlabeledUnaryExpr();
3564-
assert(unaryArg);
3565-
expr = new (CS.getASTContext()) OneWayExpr(unaryArg);
3566-
} else if (typeOperation !=
3550+
if (typeOperation !=
35673551
ConstraintGenerator::TypeOperation::None) {
35683552
// Handle the Builtin.type_join* family of calls by replacing
35693553
// them with dot_self_expr of type_expr with the type being the

test/Constraints/one_way_constraints.swift

-28
This file was deleted.

test/Constraints/one_way_solve.swift

-49
This file was deleted.

test/Constraints/rdar64890308.swift

-47
This file was deleted.

0 commit comments

Comments
 (0)