Skip to content

Commit 7b9d28d

Browse files
committed
Make diagnoseSelfAssignment a utility
1 parent 3cf7b54 commit 7b9d28d

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,10 +1333,9 @@ bool RValueTreatedAsLValueFailure::diagnoseAsError() {
13331333
return false;
13341334

13351335
if (auto assignExpr = dyn_cast<AssignExpr>(diagExpr)) {
1336-
auto &TC = getTypeChecker();
13371336
// Let's check whether this is an attempt to assign
13381337
// variable or property to itself.
1339-
if (TC.diagnoseSelfAssignment(assignExpr))
1338+
if (TypeChecker::diagnoseSelfAssignment(assignExpr))
13401339
return true;
13411340

13421341
diagExpr = assignExpr->getDest();

lib/Sema/CSFix.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,11 +885,10 @@ bool IgnoreAssignmentDestinationType::diagnose(Expr *root, bool asNote) const {
885885
// `let _ = { $0 = $0 = 42 }`. Assignment chaining results in
886886
// type mismatch between result of the previous assignment and the next.
887887
{
888-
auto &TC = cs.getTypeChecker();
889888
llvm::SaveAndRestore<AssignExpr *> anchor(AE);
890889

891890
do {
892-
if (TC.diagnoseSelfAssignment(AE))
891+
if (TypeChecker::diagnoseSelfAssignment(AE))
893892
return true;
894893
} while ((AE = dyn_cast_or_null<AssignExpr>(cs.getParentExpr(AE))));
895894
}

lib/Sema/MiscDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3983,7 +3983,7 @@ static void diagnoseDeprecatedWritableKeyPath(TypeChecker &TC, const Expr *E,
39833983
void swift::performSyntacticExprDiagnostics(TypeChecker &TC, const Expr *E,
39843984
const DeclContext *DC,
39853985
bool isExprStmt) {
3986-
TC.diagnoseSelfAssignment(E);
3986+
TypeChecker::diagnoseSelfAssignment(E);
39873987
diagSyntacticUseRestrictions(TC, E, DC, isExprStmt);
39883988
diagRecursivePropertyAccess(TC, E, DC);
39893989
diagnoseImplicitSelfUseInClosure(TC, E, DC);

lib/Sema/TypeChecker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ class TypeChecker final {
18421842
}
18431843

18441844
/// Diagnose assigning variable to itself.
1845-
bool diagnoseSelfAssignment(const Expr *E);
1845+
static bool diagnoseSelfAssignment(const Expr *E);
18461846

18471847
/// Builds a string representing a "default" generic argument list for
18481848
/// \p typeDecl. In general, this means taking the bound of each generic

0 commit comments

Comments
 (0)