Skip to content

Commit f94be56

Browse files
committed
[Sema] Decouple ConstraintSystem and TypeChecker headers
1 parent 68d7278 commit f94be56

File tree

7 files changed

+32
-3
lines changed

7 files changed

+32
-3
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616
#include "ConstraintGraph.h"
1717
#include "ConstraintSystem.h"
18+
#include "TypeChecker.h"
1819
#include "llvm/ADT/SetVector.h"
1920
#include <tuple>
2021

lib/Sema/CSClosure.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
//===----------------------------------------------------------------------===//
1818

1919
#include "ConstraintSystem.h"
20+
#include "TypeChecker.h"
21+
2022
using namespace swift;
2123
using namespace swift::constraints;
2224

lib/Sema/CSDiagnostics.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Constraint.h"
2020
#include "ConstraintSystem.h"
2121
#include "OverloadChoice.h"
22+
#include "TypeChecker.h"
2223
#include "swift/AST/ASTContext.h"
2324
#include "swift/AST/ASTNode.h"
2425
#include "swift/AST/Decl.h"

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "ConstraintGraph.h"
1717
#include "ConstraintSystem.h"
1818
#include "TypeCheckType.h"
19+
#include "TypeChecker.h"
1920
#include "swift/AST/ASTVisitor.h"
2021
#include "swift/AST/ASTWalker.h"
2122
#include "swift/AST/Expr.h"

lib/Sema/CSRanking.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//
1616
//===----------------------------------------------------------------------===//
1717
#include "ConstraintSystem.h"
18+
#include "TypeChecker.h"
1819
#include "swift/AST/GenericSignature.h"
1920
#include "swift/AST/ParameterList.h"
2021
#include "swift/AST/ProtocolConformance.h"

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "ConstraintSystem.h"
1919
#include "SolutionResult.h"
2020
#include "TypeCheckType.h"
21+
#include "TypeChecker.h"
2122
#include "swift/AST/ParameterList.h"
2223
#include "swift/AST/TypeWalker.h"
2324
#include "llvm/ADT/STLExtras.h"

lib/Sema/ConstraintSystem.h

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,20 @@
2424
#include "ConstraintGraphScope.h"
2525
#include "ConstraintLocator.h"
2626
#include "OverloadChoice.h"
27-
#include "TypeChecker.h"
27+
#include "SolutionResult.h"
28+
#include "swift/AST/ASTContext.h"
2829
#include "swift/AST/ASTNode.h"
2930
#include "swift/AST/ASTVisitor.h"
3031
#include "swift/AST/ASTWalker.h"
32+
#include "swift/AST/AnyFunctionRef.h"
33+
#include "swift/AST/DiagnosticsSema.h"
3134
#include "swift/AST/NameLookup.h"
3235
#include "swift/AST/PropertyWrappers.h"
3336
#include "swift/AST/Types.h"
3437
#include "swift/Basic/Debug.h"
3538
#include "swift/Basic/LLVM.h"
3639
#include "swift/Basic/OptionSet.h"
40+
#include "llvm/ADT/MapVector.h"
3741
#include "llvm/ADT/PointerUnion.h"
3842
#include "llvm/ADT/STLExtras.h"
3943
#include "llvm/ADT/SetOperations.h"
@@ -49,15 +53,32 @@
4953
namespace swift {
5054

5155
class Expr;
56+
class FuncDecl;
57+
class BraseStmt;
58+
enum class TypeCheckExprFlags;
5259

5360
namespace constraints {
5461

5562
class ConstraintGraph;
5663
class ConstraintGraphNode;
5764
class ConstraintSystem;
65+
class SolutionApplicationTarget;
5866

5967
} // end namespace constraints
6068

69+
// Forward declare some TypeChecker related functions
70+
// so they could be made friends of ConstraintSystem.
71+
namespace TypeChecker {
72+
73+
Optional<BraceStmt *> applyFunctionBuilderBodyTransform(FuncDecl *func,
74+
Type builderType);
75+
76+
Optional<constraints::SolutionApplicationTarget>
77+
typeCheckExpression(constraints::SolutionApplicationTarget &target,
78+
OptionSet<TypeCheckExprFlags> options);
79+
80+
} // end namespace TypeChecker
81+
6182
} // end namespace swift
6283

6384
/// Allocate memory within the given constraint system.
@@ -2730,9 +2751,10 @@ class ConstraintSystem {
27302751
friend Optional<BraceStmt *>
27312752
swift::TypeChecker::applyFunctionBuilderBodyTransform(FuncDecl *func,
27322753
Type builderType);
2754+
27332755
friend Optional<SolutionApplicationTarget>
2734-
swift::TypeChecker::typeCheckExpression(SolutionApplicationTarget &target,
2735-
TypeCheckExprOptions options);
2756+
swift::TypeChecker::typeCheckExpression(
2757+
SolutionApplicationTarget &target, OptionSet<TypeCheckExprFlags> options);
27362758

27372759
/// Emit the fixes computed as part of the solution, returning true if we were
27382760
/// able to emit an error message, or false if none of the fixits worked out.

0 commit comments

Comments
 (0)