Skip to content

Commit

Permalink
[TypeChecker] NFC: Include constraint system into TypeChecker header
Browse files Browse the repository at this point in the history
Avoids having to include ConstraintSystem.h in TypeCheck*.cpp
files to gain access to ContextualInfo and related classes.
  • Loading branch information
xedin committed Oct 6, 2020
1 parent f94be56 commit 0b648fb
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 15 deletions.
1 change: 0 additions & 1 deletion lib/Sema/DebuggerTestingTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "swift/Subsystems.h"

#include "TypeChecker.h"
#include "ConstraintSystem.h"

using namespace swift;

Expand Down
1 change: 0 additions & 1 deletion lib/Sema/InstrumenterSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//===----------------------------------------------------------------------===//

#include "TypeChecker.h"
#include "ConstraintSystem.h"
#include "swift/AST/ASTWalker.h"

namespace swift {
Expand Down
3 changes: 1 addition & 2 deletions lib/Sema/TypeCheckCodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,7 @@ bool swift::typeCheckExpression(DeclContext *DC, Expr *&parsedExpr) {
parsedExpr = parsedExpr->walk(SanitizeExpr(ctx, /*shouldReusePrecheckedType=*/false));

DiagnosticSuppression suppression(ctx.Diags);
auto resultTy =
TypeChecker::typeCheckExpression(parsedExpr, DC, /*contextualInfo=*/{});
auto resultTy = TypeChecker::typeCheckExpression(parsedExpr, DC);
return !resultTy;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ bool TypeChecker::typeCheckCondition(Expr *&expr, DeclContext *dc) {
// re-typecheck it.
if (expr->getType() && expr->getType()->isBool()) {
auto resultTy =
TypeChecker::typeCheckExpression(expr, dc, /*contextualInfo=*/{});
TypeChecker::typeCheckExpression(expr, dc);
return !resultTy;
}

Expand Down
1 change: 0 additions & 1 deletion lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//===----------------------------------------------------------------------===//

#include "CodeSynthesis.h"
#include "ConstraintSystem.h"
#include "DerivedConformances.h"
#include "TypeChecker.h"
#include "TypeCheckAccess.h"
Expand Down
6 changes: 2 additions & 4 deletions lib/Sema/TypeCheckStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "TypeCheckAvailability.h"
#include "TypeCheckType.h"
#include "MiscDiagnostics.h"
#include "ConstraintSystem.h"
#include "swift/Subsystems.h"
#include "swift/AST/ASTPrinter.h"
#include "swift/AST/ASTWalker.h"
Expand Down Expand Up @@ -882,7 +881,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
TypeChecker::typeCheckDecl(DS->getTempDecl());

Expr *theCall = DS->getCallExpr();
TypeChecker::typeCheckExpression(theCall, DC, /*contextualInfo=*/{});
TypeChecker::typeCheckExpression(theCall, DC);
DS->setCallExpr(theCall);

return DS;
Expand Down Expand Up @@ -1156,8 +1155,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
Stmt *visitSwitchStmt(SwitchStmt *switchStmt) {
// Type-check the subject expression.
Expr *subjectExpr = switchStmt->getSubjectExpr();
auto resultTy = TypeChecker::typeCheckExpression(subjectExpr, DC,
/*contextualInfo=*/{});
auto resultTy = TypeChecker::typeCheckExpression(subjectExpr, DC);
auto limitExhaustivityChecks = !resultTy;
if (Expr *newSubjectExpr =
TypeChecker::coerceToRValue(getASTContext(), subjectExpr))
Expand Down
4 changes: 1 addition & 3 deletions lib/Sema/TypeCheckStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "CodeSynthesis.h"
#include "TypeChecker.h"
#include "ConstraintSystem.h"
#include "TypeCheckAvailability.h"
#include "TypeCheckDecl.h"
#include "TypeCheckType.h"
Expand Down Expand Up @@ -917,8 +916,7 @@ static Expr *buildStorageReference(AccessorDecl *accessor,
// FIXME: Since we're not resolving overloads or anything, we should be
// building fully type-checked AST above; we already have all the
// information that we need.
if (!TypeChecker::typeCheckExpression(lookupExpr, accessor,
/*contextualInfo=*/{}))
if (!TypeChecker::typeCheckExpression(lookupExpr, accessor))
return nullptr;

// Make sure we produce an lvalue only when desired.
Expand Down
4 changes: 2 additions & 2 deletions lib/Sema/TypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef TYPECHECKING_H
#define TYPECHECKING_H

#include "ConstraintSystem.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/AccessScope.h"
#include "swift/AST/AnyFunctionRef.h"
Expand Down Expand Up @@ -51,7 +52,6 @@ namespace constraints {
class Solution;
class SolutionApplicationTarget;
class SolutionResult;
struct ContextualTypeInfo;
}

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

Optional<constraints::SolutionApplicationTarget>
Expand Down

0 comments on commit 0b648fb

Please sign in to comment.