Skip to content

Commit deab5f7

Browse files
authored
Merge pull request #84280 from hamishknight/csapply-cleanup
Reapply: [Sema] Remove some unreachable code from CSApply
2 parents 5a46664 + 3484f63 commit deab5f7

File tree

12 files changed

+51
-180
lines changed

12 files changed

+51
-180
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,6 @@ ERROR(cannot_apply_lvalue_binop_to_subelement,none,
254254
ERROR(cannot_apply_lvalue_binop_to_rvalue,none,
255255
"left side of mutating operator has immutable type %0", (Type))
256256

257-
ERROR(cannot_subscript_base,none,
258-
"cannot subscript a value of type %0",
259-
(Type))
260-
261-
ERROR(cannot_subscript_ambiguous_base,none,
262-
"cannot subscript a value of incorrect or ambiguous type", ())
263-
264257
ERROR(cannot_subscript_nil_literal,none,
265258
"cannot subscript a nil literal value", ())
266259
ERROR(conditional_cast_from_nil,none,

include/swift/AST/Expr.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,24 +3348,9 @@ class ABISafeConversionExpr : public ImplicitConversionExpr {
33483348
}
33493349
};
33503350

3351-
/// This is a conversion from an expression of UnresolvedType to an arbitrary
3352-
/// other type, and from an arbitrary type to UnresolvedType. This node does
3353-
/// not appear in valid code, only in code involving diagnostics.
3354-
class UnresolvedTypeConversionExpr : public ImplicitConversionExpr {
3355-
public:
3356-
UnresolvedTypeConversionExpr(Expr *subExpr, Type type)
3357-
: ImplicitConversionExpr(ExprKind::UnresolvedTypeConversion, subExpr, type) {}
3358-
3359-
static bool classof(const Expr *E) {
3360-
return E->getKind() == ExprKind::UnresolvedTypeConversion;
3361-
}
3362-
};
3363-
33643351
/// FunctionConversionExpr - Convert a function to another function type,
33653352
/// which might involve renaming the parameters or handling substitutions
33663353
/// of subtypes (in the return) or supertypes (in the input).
3367-
///
3368-
/// FIXME: This should be a CapturingExpr.
33693354
class FunctionConversionExpr : public ImplicitConversionExpr {
33703355
public:
33713356
FunctionConversionExpr(Expr *subExpr, Type type)

include/swift/AST/ExprNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ ABSTRACT_EXPR(ImplicitConversion, Expr)
161161
EXPR(Load, ImplicitConversionExpr)
162162
EXPR(ABISafeConversion, ImplicitConversionExpr)
163163
EXPR(DestructureTuple, ImplicitConversionExpr)
164-
EXPR(UnresolvedTypeConversion, ImplicitConversionExpr)
165164
EXPR(FunctionConversion, ImplicitConversionExpr)
166165
EXPR(CovariantFunctionConversion, ImplicitConversionExpr)
167166
EXPR(CovariantReturnConversion, ImplicitConversionExpr)

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ class Solution {
17641764
/// Retrieve the overload choice associated with the given
17651765
/// locator.
17661766
SelectedOverload getOverloadChoice(ConstraintLocator *locator) const {
1767-
return *getOverloadChoiceIfAvailable(locator);
1767+
return getOverloadChoiceIfAvailable(locator).value();
17681768
}
17691769

17701770
/// Retrieve the overload choice for the callee associated with the given

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,12 +3817,6 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, Label>,
38173817

38183818
printFoot();
38193819
}
3820-
void visitUnresolvedTypeConversionExpr(UnresolvedTypeConversionExpr *E,
3821-
Label label) {
3822-
printCommon(E, "unresolvedtype_conversion_expr", label);
3823-
printRec(E->getSubExpr(), Label::optional("sub_expr"));
3824-
printFoot();
3825-
}
38263820
void visitFunctionConversionExpr(FunctionConversionExpr *E, Label label) {
38273821
printCommon(E, "function_conversion_expr", label);
38283822
printRec(E->getSubExpr(), Label::optional("sub_expr"));

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5558,9 +5558,6 @@ void PrintAST::visitMakeTemporarilyEscapableExpr(MakeTemporarilyEscapableExpr *e
55585558
void PrintAST::visitProtocolMetatypeToObjectExpr(ProtocolMetatypeToObjectExpr *expr) {
55595559
}
55605560

5561-
void PrintAST::visitUnresolvedTypeConversionExpr(UnresolvedTypeConversionExpr *expr) {
5562-
}
5563-
55645561
void PrintAST::visitConditionalBridgeFromObjCExpr(ConditionalBridgeFromObjCExpr *expr) {
55655562
}
55665563

lib/AST/Expr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ ConcreteDeclRef Expr::getReferencedDecl(bool stopAtParenExpr) const {
414414

415415
PASS_THROUGH_REFERENCE(Load, getSubExpr);
416416
NO_REFERENCE(DestructureTuple);
417-
NO_REFERENCE(UnresolvedTypeConversion);
418417
PASS_THROUGH_REFERENCE(ABISafeConversion, getSubExpr);
419418
PASS_THROUGH_REFERENCE(FunctionConversion, getSubExpr);
420419
PASS_THROUGH_REFERENCE(CovariantFunctionConversion, getSubExpr);
@@ -783,7 +782,6 @@ bool Expr::canAppendPostfixExpression(bool appendingPostfixOperator) const {
783782
case ExprKind::Load:
784783
case ExprKind::ABISafeConversion:
785784
case ExprKind::DestructureTuple:
786-
case ExprKind::UnresolvedTypeConversion:
787785
case ExprKind::FunctionConversion:
788786
case ExprKind::CovariantFunctionConversion:
789787
case ExprKind::CovariantReturnConversion:
@@ -993,7 +991,6 @@ bool Expr::isValidParentOfTypeExpr(Expr *typeExpr) const {
993991
case ExprKind::Binary:
994992
case ExprKind::Load:
995993
case ExprKind::DestructureTuple:
996-
case ExprKind::UnresolvedTypeConversion:
997994
case ExprKind::ABISafeConversion:
998995
case ExprKind::FunctionConversion:
999996
case ExprKind::CovariantFunctionConversion:

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,6 @@ namespace {
481481
RValue visitConditionalBridgeFromObjCExpr(ConditionalBridgeFromObjCExpr *E,
482482
SGFContext C);
483483
RValue visitArchetypeToSuperExpr(ArchetypeToSuperExpr *E, SGFContext C);
484-
RValue visitUnresolvedTypeConversionExpr(UnresolvedTypeConversionExpr *E,
485-
SGFContext C);
486484
RValue visitABISafeConversionExpr(ABISafeConversionExpr *E, SGFContext C) {
487485
llvm_unreachable("cannot appear in rvalue");
488486
}
@@ -1035,12 +1033,6 @@ RValue RValueEmitter::visitSuperRefExpr(SuperRefExpr *E, SGFContext C) {
10351033
return RValue(SGF, E, result);
10361034
}
10371035

1038-
RValue RValueEmitter::
1039-
visitUnresolvedTypeConversionExpr(UnresolvedTypeConversionExpr *E,
1040-
SGFContext C) {
1041-
llvm_unreachable("invalid code made its way into SILGen");
1042-
}
1043-
10441036
RValue RValueEmitter::visitOtherConstructorDeclRefExpr(
10451037
OtherConstructorDeclRefExpr *E, SGFContext C) {
10461038
// This should always be a child of an ApplyExpr and so will be emitted by

0 commit comments

Comments
 (0)