Skip to content

Commit 0b648fb

Browse files
committed
[TypeChecker] NFC: Include constraint system into TypeChecker header
Avoids having to include ConstraintSystem.h in TypeCheck*.cpp files to gain access to ContextualInfo and related classes.
1 parent f94be56 commit 0b648fb

8 files changed

+7
-15
lines changed

lib/Sema/DebuggerTestingTransform.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "swift/Subsystems.h"
3030

3131
#include "TypeChecker.h"
32-
#include "ConstraintSystem.h"
3332

3433
using namespace swift;
3534

lib/Sema/InstrumenterSupport.h

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
//===----------------------------------------------------------------------===//
1717

1818
#include "TypeChecker.h"
19-
#include "ConstraintSystem.h"
2019
#include "swift/AST/ASTWalker.h"
2120

2221
namespace swift {

lib/Sema/TypeCheckCodeCompletion.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,7 @@ bool swift::typeCheckExpression(DeclContext *DC, Expr *&parsedExpr) {
962962
parsedExpr = parsedExpr->walk(SanitizeExpr(ctx, /*shouldReusePrecheckedType=*/false));
963963

964964
DiagnosticSuppression suppression(ctx.Diags);
965-
auto resultTy =
966-
TypeChecker::typeCheckExpression(parsedExpr, DC, /*contextualInfo=*/{});
965+
auto resultTy = TypeChecker::typeCheckExpression(parsedExpr, DC);
967966
return !resultTy;
968967
}
969968

lib/Sema/TypeCheckConstraints.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ bool TypeChecker::typeCheckCondition(Expr *&expr, DeclContext *dc) {
594594
// re-typecheck it.
595595
if (expr->getType() && expr->getType()->isBool()) {
596596
auto resultTy =
597-
TypeChecker::typeCheckExpression(expr, dc, /*contextualInfo=*/{});
597+
TypeChecker::typeCheckExpression(expr, dc);
598598
return !resultTy;
599599
}
600600

lib/Sema/TypeCheckDecl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "CodeSynthesis.h"
18-
#include "ConstraintSystem.h"
1918
#include "DerivedConformances.h"
2019
#include "TypeChecker.h"
2120
#include "TypeCheckAccess.h"

lib/Sema/TypeCheckStmt.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "TypeCheckAvailability.h"
1919
#include "TypeCheckType.h"
2020
#include "MiscDiagnostics.h"
21-
#include "ConstraintSystem.h"
2221
#include "swift/Subsystems.h"
2322
#include "swift/AST/ASTPrinter.h"
2423
#include "swift/AST/ASTWalker.h"
@@ -882,7 +881,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
882881
TypeChecker::typeCheckDecl(DS->getTempDecl());
883882

884883
Expr *theCall = DS->getCallExpr();
885-
TypeChecker::typeCheckExpression(theCall, DC, /*contextualInfo=*/{});
884+
TypeChecker::typeCheckExpression(theCall, DC);
886885
DS->setCallExpr(theCall);
887886

888887
return DS;
@@ -1156,8 +1155,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
11561155
Stmt *visitSwitchStmt(SwitchStmt *switchStmt) {
11571156
// Type-check the subject expression.
11581157
Expr *subjectExpr = switchStmt->getSubjectExpr();
1159-
auto resultTy = TypeChecker::typeCheckExpression(subjectExpr, DC,
1160-
/*contextualInfo=*/{});
1158+
auto resultTy = TypeChecker::typeCheckExpression(subjectExpr, DC);
11611159
auto limitExhaustivityChecks = !resultTy;
11621160
if (Expr *newSubjectExpr =
11631161
TypeChecker::coerceToRValue(getASTContext(), subjectExpr))

lib/Sema/TypeCheckStorage.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "CodeSynthesis.h"
1919
#include "TypeChecker.h"
20-
#include "ConstraintSystem.h"
2120
#include "TypeCheckAvailability.h"
2221
#include "TypeCheckDecl.h"
2322
#include "TypeCheckType.h"
@@ -917,8 +916,7 @@ static Expr *buildStorageReference(AccessorDecl *accessor,
917916
// FIXME: Since we're not resolving overloads or anything, we should be
918917
// building fully type-checked AST above; we already have all the
919918
// information that we need.
920-
if (!TypeChecker::typeCheckExpression(lookupExpr, accessor,
921-
/*contextualInfo=*/{}))
919+
if (!TypeChecker::typeCheckExpression(lookupExpr, accessor))
922920
return nullptr;
923921

924922
// Make sure we produce an lvalue only when desired.

lib/Sema/TypeChecker.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef TYPECHECKING_H
1818
#define TYPECHECKING_H
1919

20+
#include "ConstraintSystem.h"
2021
#include "swift/AST/ASTContext.h"
2122
#include "swift/AST/AccessScope.h"
2223
#include "swift/AST/AnyFunctionRef.h"
@@ -51,7 +52,6 @@ namespace constraints {
5152
class Solution;
5253
class SolutionApplicationTarget;
5354
class SolutionResult;
54-
struct ContextualTypeInfo;
5555
}
5656

5757
/// Special-case type checking semantics for certain declarations.
@@ -561,7 +561,7 @@ Expr *findLHS(DeclContext *DC, Expr *E, Identifier name);
561561
/// \returns The type of the top-level expression, or Type() if an
562562
/// error occurred.
563563
Type typeCheckExpression(Expr *&expr, DeclContext *dc,
564-
constraints::ContextualTypeInfo contextualInfo,
564+
constraints::ContextualTypeInfo contextualInfo = {},
565565
TypeCheckExprOptions options = TypeCheckExprOptions());
566566

567567
Optional<constraints::SolutionApplicationTarget>

0 commit comments

Comments
 (0)