Skip to content

Commit 67fb143

Browse files
committed
[AST] Remove ReifyPackExpr.
1 parent c7f348f commit 67fb143

File tree

12 files changed

+2
-71
lines changed

12 files changed

+2
-71
lines changed

include/swift/AST/Expr.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,18 +3399,6 @@ class BridgeToObjCExpr : public ImplicitConversionExpr {
33993399
}
34003400
};
34013401

3402-
/// ReifyPackExpr - Drop the pack structure and reify it either as a tuple or
3403-
/// single value.
3404-
class ReifyPackExpr : public ImplicitConversionExpr {
3405-
public:
3406-
ReifyPackExpr(Expr *subExpr, Type type)
3407-
: ImplicitConversionExpr(ExprKind::ReifyPack, subExpr, type) {}
3408-
3409-
static bool classof(const Expr *E) {
3410-
return E->getKind() == ExprKind::ReifyPack;
3411-
}
3412-
};
3413-
34143402
/// UnresolvedSpecializeExpr - Represents an explicit specialization using
34153403
/// a type parameter list (e.g. "Vector<Int>") that has not been resolved.
34163404
class UnresolvedSpecializeExpr final : public Expr,
@@ -5926,8 +5914,7 @@ class OneWayExpr : public Expr {
59265914
///
59275915
/// There is no user-visible way to spell a pack expression, they are always
59285916
/// implicitly created at applies. As such, any appearance of pack types outside
5929-
/// of applies are illegal. In general, packs appearing in such positions should
5930-
/// have a \c ReifyPackExpr to convert them to a user-available AST type.
5917+
/// of applies are illegal.
59315918
class PackExpr final : public Expr,
59325919
private llvm::TrailingObjects<PackExpr, Expr *> {
59335920
friend TrailingObjects;

include/swift/AST/ExprNodes.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ ABSTRACT_EXPR(ImplicitConversion, Expr)
184184
EXPR(DifferentiableFunctionExtractOriginal, ImplicitConversionExpr)
185185
EXPR(LinearFunctionExtractOriginal, ImplicitConversionExpr)
186186
EXPR(LinearToDifferentiableFunction, ImplicitConversionExpr)
187-
EXPR(ReifyPack, ImplicitConversionExpr)
188-
EXPR_RANGE(ImplicitConversion, Load, ReifyPack)
187+
EXPR_RANGE(ImplicitConversion, Load, LinearToDifferentiableFunction)
189188
ABSTRACT_EXPR(ExplicitCast, Expr)
190189
ABSTRACT_EXPR(CheckedCast, ExplicitCastExpr)
191190
EXPR(ForcedCheckedCast, CheckedCastExpr)

include/swift/Sema/Constraint.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,6 @@ enum class ConversionRestrictionKind {
307307
/// - Unsafe[Mutable]RawPointer -> Unsafe[Mutable]Pointer<[U]Int>
308308
/// - Unsafe[Mutable]Pointer<Int{8, 16, ...}> <-> Unsafe[Mutable]Pointer<UInt{8, 16, ...}>
309309
PointerToCPointer,
310-
// Convert a pack into a type with an equivalent arity.
311-
// - If the arity of the pack is 1, drops the pack structure <T> => T
312-
// - If the arity of the pack is n >= 1, converts the pack structure into a tuple <T, U, V> => (T, U, V)
313-
ReifyPackToType,
314310
};
315311

316312
/// Specifies whether a given conversion requires the creation of a temporary

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,11 +2295,6 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
22952295
printRec(E->getSubExpr());
22962296
PrintWithColorRAII(OS, ParenthesisColor) << ')';
22972297
}
2298-
void visitReifyPackExpr(ReifyPackExpr *E) {
2299-
printCommon(E, "reify_pack") << '\n';
2300-
printRec(E->getSubExpr());
2301-
PrintWithColorRAII(OS, ParenthesisColor) << ')';
2302-
}
23032298
void visitLoadExpr(LoadExpr *E) {
23042299
printCommon(E, "load_expr") << '\n';
23052300
printRec(E->getSubExpr());

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,9 +4587,6 @@ void PrintAST::visitTupleExpr(TupleExpr *expr) {
45874587
void PrintAST::visitPackExpr(PackExpr *expr) {
45884588
}
45894589

4590-
void PrintAST::visitReifyPackExpr(ReifyPackExpr *expr) {
4591-
}
4592-
45934590
void PrintAST::visitTypeJoinExpr(TypeJoinExpr *expr) {
45944591
}
45954592

lib/AST/Expr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ ConcreteDeclRef Expr::getReferencedDecl(bool stopAtParenExpr) const {
444444
PASS_THROUGH_REFERENCE(BridgeFromObjC, getSubExpr);
445445
PASS_THROUGH_REFERENCE(ConditionalBridgeFromObjC, getSubExpr);
446446
PASS_THROUGH_REFERENCE(UnderlyingToOpaque, getSubExpr);
447-
PASS_THROUGH_REFERENCE(ReifyPack, getSubExpr);
448447
NO_REFERENCE(Coerce);
449448
NO_REFERENCE(ForcedCheckedCast);
450449
NO_REFERENCE(ConditionalCheckedCast);
@@ -794,7 +793,6 @@ bool Expr::canAppendPostfixExpression(bool appendingPostfixOperator) const {
794793
case ExprKind::BridgeFromObjC:
795794
case ExprKind::BridgeToObjC:
796795
case ExprKind::UnderlyingToOpaque:
797-
case ExprKind::ReifyPack:
798796
// Implicit conversion nodes have no syntax of their own; defer to the
799797
// subexpression.
800798
return cast<ImplicitConversionExpr>(this)->getSubExpr()
@@ -983,7 +981,6 @@ bool Expr::isValidParentOfTypeExpr(Expr *typeExpr) const {
983981
case ExprKind::KeyPathDot:
984982
case ExprKind::OneWay:
985983
case ExprKind::Tap:
986-
case ExprKind::ReifyPack:
987984
case ExprKind::Pack:
988985
case ExprKind::TypeJoin:
989986
return false;

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ namespace {
446446
CollectionUpcastConversionExpr *E,
447447
SGFContext C);
448448
RValue visitBridgeToObjCExpr(BridgeToObjCExpr *E, SGFContext C);
449-
RValue visitReifyPackExpr(ReifyPackExpr *E, SGFContext C);
450449
RValue visitPackExpansionExpr(PackExpansionExpr *E, SGFContext C);
451450
RValue visitBridgeFromObjCExpr(BridgeFromObjCExpr *E, SGFContext C);
452451
RValue visitConditionalBridgeFromObjCExpr(ConditionalBridgeFromObjCExpr *E,
@@ -1513,11 +1512,6 @@ RValueEmitter::visitBridgeToObjCExpr(BridgeToObjCExpr *E, SGFContext C) {
15131512
return RValue(SGF, E, result);
15141513
}
15151514

1516-
RValue
1517-
RValueEmitter::visitReifyPackExpr(ReifyPackExpr *E, SGFContext C) {
1518-
llvm_unreachable("Unimplemented!");
1519-
}
1520-
15211515
RValue
15221516
RValueEmitter::visitPackExpansionExpr(PackExpansionExpr *E,
15231517
SGFContext C) {

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7011,11 +7011,6 @@ Expr *ExprRewriter::coerceToType(Expr *expr, Type toType,
70117011
finishApply(implicitInit, toType, callLocator, callLocator);
70127012
return implicitInit;
70137013
}
7014-
case ConversionRestrictionKind::ReifyPackToType: {
7015-
auto reifyPack =
7016-
cs.cacheType(new (ctx) ReifyPackExpr(expr, toType));
7017-
return coerceToType(reifyPack, toType, locator);
7018-
}
70197014
}
70207015
}
70217016

lib/Sema/CSDiagnostics.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7174,7 +7174,6 @@ void NonEphemeralConversionFailure::emitSuggestionNotes() const {
71747174
case ConversionRestrictionKind::ObjCTollFreeBridgeToCF:
71757175
case ConversionRestrictionKind::CGFloatToDouble:
71767176
case ConversionRestrictionKind::DoubleToCGFloat:
7177-
case ConversionRestrictionKind::ReifyPackToType:
71787177
llvm_unreachable("Expected an ephemeral conversion!");
71797178
}
71807179
}

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6834,15 +6834,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
68346834
}
68356835
}
68366836
}
6837-
6838-
// A Pack of (Ts...) is convertible to a tuple (X, Y, Z) as long as there
6839-
// is an element-wise match.
6840-
if (auto *expansionTy = type1->getAs<PackType>()) {
6841-
if (!type2->isTypeVariableOrMember()) {
6842-
conversionsOrFixes.push_back(
6843-
ConversionRestrictionKind::ReifyPackToType);
6844-
}
6845-
}
68466837
}
68476838

68486839
if (kind >= ConstraintKind::OperatorArgumentConversion) {
@@ -12679,22 +12670,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
1267912670
{getConstraintLocator(locator), restriction});
1268012671
return SolutionKind::Solved;
1268112672
}
12682-
case ConversionRestrictionKind::ReifyPackToType: {
12683-
type1 = simplifyType(type1);
12684-
auto *PET = type1->castTo<PackType>();
12685-
if (auto *TT = type2->getAs<TupleType>()) {
12686-
llvm::SmallVector<TupleTypeElt, 8> elts;
12687-
for (Type elt : PET->getElementTypes()) {
12688-
elts.push_back(elt);
12689-
}
12690-
Type tupleType1 = TupleType::get(elts, getASTContext());
12691-
return matchTypes(tupleType1, TT, ConstraintKind::Bind, subflags,
12692-
locator);
12693-
} else {
12694-
return matchTypes(PET->getElementType(0), type2, ConstraintKind::Bind,
12695-
subflags, locator);
12696-
}
12697-
}
1269812673
}
1269912674

1270012675
llvm_unreachable("bad conversion restriction");

0 commit comments

Comments
 (0)