Skip to content

Commit e6bdd11

Browse files
rintarorudkx
authored andcommitted
[AST] Remove DefaultValueExpr type (#4713)
The last instantiation of this type was removed in 68bcb0d (cherry picked from commit 339387e)
1 parent 5c0d395 commit e6bdd11

File tree

9 files changed

+3
-75
lines changed

9 files changed

+3
-75
lines changed

include/swift/AST/Expr.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,29 +4299,6 @@ class AssignExpr : public Expr {
42994299
}
43004300
};
43014301

4302-
/// \brief An expression that describes the use of a default value, which may
4303-
/// come from the default argument of a function type or member initializer.
4304-
///
4305-
/// This expression is synthesized by type checking and cannot be written
4306-
/// directly by the user.
4307-
class DefaultValueExpr : public Expr {
4308-
Expr *subExpr;
4309-
4310-
public:
4311-
explicit DefaultValueExpr(Expr *subExpr)
4312-
: Expr(ExprKind::DefaultValue, /*Implicit=*/true, subExpr->getType()),
4313-
subExpr(subExpr) { }
4314-
4315-
Expr *getSubExpr() const { return subExpr; }
4316-
void setSubExpr(Expr *sub) { subExpr = sub; }
4317-
4318-
SourceRange getSourceRange() const { return SourceRange(); }
4319-
4320-
static bool classof(const Expr *E) {
4321-
return E->getKind() == ExprKind::DefaultValue;
4322-
}
4323-
};
4324-
43254302
/// \brief A pattern production that has been parsed but hasn't been resolved
43264303
/// into a complete pattern. Name binding converts these into standalone pattern
43274304
/// nodes or raises an error if a pattern production appears in an invalid

include/swift/AST/ExprNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ UNCHECKED_EXPR(Arrow, Expr)
154154
EXPR(If, Expr)
155155
EXPR(EnumIsCase, Expr)
156156
EXPR(Assign, Expr)
157-
EXPR(DefaultValue, Expr)
158157
EXPR(CodeCompletion, Expr)
159158
UNCHECKED_EXPR(UnresolvedPattern, Expr)
160159
EXPR(EditorPlaceholder, Expr)

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,11 +2212,6 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
22122212
printRec(E->getElseExpr());
22132213
OS << ')';
22142214
}
2215-
void visitDefaultValueExpr(DefaultValueExpr *E) {
2216-
printCommon(E, "default_value_expr") << ' ';
2217-
printRec(E->getSubExpr());
2218-
OS << ')';
2219-
}
22202215
void visitAssignExpr(AssignExpr *E) {
22212216
OS.indent(Indent) << "(assign_expr\n";
22222217
printRec(E->getDest());

lib/AST/ASTWalker.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,14 +800,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
800800
return E;
801801
}
802802

803-
Expr *visitDefaultValueExpr(DefaultValueExpr *E) {
804-
Expr *sub = doIt(E->getSubExpr());
805-
if (!sub) return nullptr;
806-
807-
E->setSubExpr(sub);
808-
return E;
809-
}
810-
811803
Expr *visitUnresolvedPatternExpr(UnresolvedPatternExpr *E) {
812804
Pattern *sub = doIt(E->getSubPattern());
813805
if (!sub) return nullptr;

lib/AST/Expr.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,6 @@ Expr *Expr::getSemanticsProvidingExpr() {
178178
if (TryExpr *TE = dyn_cast<TryExpr>(this))
179179
return TE->getSubExpr()->getSemanticsProvidingExpr();
180180

181-
if (DefaultValueExpr *DE = dyn_cast<DefaultValueExpr>(this))
182-
return DE->getSubExpr()->getSemanticsProvidingExpr();
183-
184181
return this;
185182
}
186183

@@ -343,7 +340,6 @@ void Expr::propagateLValueAccessKind(AccessKind accessKind,
343340
NON_LVALUE_EXPR(OptionalEvaluation)
344341
NON_LVALUE_EXPR(If)
345342
NON_LVALUE_EXPR(Assign)
346-
NON_LVALUE_EXPR(DefaultValue)
347343
NON_LVALUE_EXPR(CodeCompletion)
348344
NON_LVALUE_EXPR(ObjCSelector)
349345
NON_LVALUE_EXPR(ObjCKeyPath)
@@ -485,7 +481,6 @@ ConcreteDeclRef Expr::getReferencedDecl() const {
485481
NO_REFERENCE(If);
486482
NO_REFERENCE(EnumIsCase);
487483
NO_REFERENCE(Assign);
488-
NO_REFERENCE(DefaultValue);
489484
NO_REFERENCE(CodeCompletion);
490485
NO_REFERENCE(UnresolvedPattern);
491486
NO_REFERENCE(EditorPlaceholder);
@@ -784,7 +779,6 @@ bool Expr::canAppendCallParentheses() const {
784779
case ExprKind::Arrow:
785780
case ExprKind::If:
786781
case ExprKind::Assign:
787-
case ExprKind::DefaultValue:
788782
case ExprKind::UnresolvedPattern:
789783
case ExprKind::EditorPlaceholder:
790784
return false;

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ namespace {
214214
SGFContext C);
215215
RValue visitIfExpr(IfExpr *E, SGFContext C);
216216

217-
RValue visitDefaultValueExpr(DefaultValueExpr *E, SGFContext C);
218217
RValue visitAssignExpr(AssignExpr *E, SGFContext C);
219218
RValue visitEnumIsCaseExpr(EnumIsCaseExpr *E, SGFContext C);
220219

@@ -2581,10 +2580,6 @@ RValue RValueEmitter::visitIfExpr(IfExpr *E, SGFContext C) {
25812580
}
25822581
}
25832582

2584-
RValue RValueEmitter::visitDefaultValueExpr(DefaultValueExpr *E, SGFContext C) {
2585-
return visit(E->getSubExpr(), C);
2586-
}
2587-
25882583
RValue SILGenFunction::emitEmptyTupleRValue(SILLocation loc,
25892584
SGFContext C) {
25902585
return RValue(CanType(TupleType::getEmpty(F.getASTContext())));

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,10 +2869,6 @@ namespace {
28692869
llvm_unreachable("Already type-checked");
28702870
}
28712871

2872-
Expr *visitDefaultValueExpr(DefaultValueExpr *expr) {
2873-
llvm_unreachable("Already type-checked");
2874-
}
2875-
28762872
Expr *visitApplyExpr(ApplyExpr *expr) {
28772873
return finishApply(expr, expr->getType(),
28782874
ConstraintLocatorBuilder(
@@ -6456,10 +6452,6 @@ namespace {
64566452
}
64576453

64586454
std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
6459-
// For a default-value expression, do nothing.
6460-
if (isa<DefaultValueExpr>(expr))
6461-
return { false, expr };
6462-
64636455
// For closures, update the parameter types and check the body.
64646456
if (auto closure = dyn_cast<ClosureExpr>(expr)) {
64656457
Rewriter.simplifyExprType(expr);

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,11 +2310,6 @@ namespace {
23102310
return expr->getType();
23112311
}
23122312

2313-
Type visitDefaultValueExpr(DefaultValueExpr *expr) {
2314-
expr->setType(expr->getSubExpr()->getType());
2315-
return expr->getType();
2316-
}
2317-
23182313
Type visitApplyExpr(ApplyExpr *expr) {
23192314
Type outputTy;
23202315

@@ -2757,11 +2752,6 @@ namespace {
27572752
public:
27582753
SanitizeExpr(TypeChecker &tc) : TC(tc) { }
27592754

2760-
std::pair<bool, Expr *> walkToExprPre(Expr *expr) override {
2761-
// Don't recurse into default-value expressions.
2762-
return { !isa<DefaultValueExpr>(expr), expr };
2763-
}
2764-
27652755
Expr *walkToExprPost(Expr *expr) override {
27662756
if (auto implicit = dyn_cast<ImplicitConversionExpr>(expr)) {
27672757
// Skip implicit conversions completely.
@@ -2841,12 +2831,6 @@ namespace {
28412831
return { true, expr };
28422832
}
28432833

2844-
// We don't visit default value expressions; they've already been
2845-
// type-checked.
2846-
if (isa<DefaultValueExpr>(expr)) {
2847-
return { false, expr };
2848-
}
2849-
28502834
// Don't visit CoerceExpr with an empty sub expression. They may occur
28512835
// if the body of a closure was not visited while pre-checking because
28522836
// of an error in the closure's signature

lib/Sema/CSSolver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,9 +1526,9 @@ void ConstraintSystem::shrink(Expr *expr) {
15261526
return {false, expr};
15271527
}
15281528

1529-
// Let's not attempt to type-check closures or default values,
1530-
// which has already been type checked anyway.
1531-
if (isa<ClosureExpr>(expr) || isa<DefaultValueExpr>(expr)) {
1529+
// Let's not attempt to type-check closures, which has already been
1530+
// type checked anyway.
1531+
if (isa<ClosureExpr>(expr)) {
15321532
return { false, expr };
15331533
}
15341534

0 commit comments

Comments
 (0)