[CS] NFC: Store ContextualTypeInfo in SyntacticElementTarget

Move the contextual type locator onto
ContextualTypeInfo, and consolidate the separate
fields in SyntacticElementTarget into storing a
ContextualTypeInfo. This then lets us plumb down
the locator for the branch contextual type of an
if/switch expression from the initial constraint
generation, rather than introducing it later. This
should be NFC.
This commit is contained in:
Hamish Knight
2023-07-26 16:46:54 +01:00
parent 61d73d2b6f
commit a64ba23d7b
10 changed files with 151 additions and 146 deletions

View File

@@ -25,6 +25,7 @@
#include "swift/AST/TypeLoc.h"
#include "swift/Basic/Debug.h"
#include "swift/Sema/ConstraintLocator.h"
#include "swift/Sema/ContextualTypeInfo.h"
#include "swift/Sema/OverloadChoice.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/ilist.h"
@@ -50,23 +51,6 @@ class ConstraintLocator;
class ConstraintSystem;
enum class TrailingClosureMatching;
/// Describes contextual type information about a particular element
/// (expression, statement etc.) within a constraint system.
struct ContextualTypeInfo {
TypeLoc typeLoc;
ContextualTypePurpose purpose;
ContextualTypeInfo() : typeLoc(TypeLoc()), purpose(CTP_Unused) {}
ContextualTypeInfo(Type contextualTy, ContextualTypePurpose purpose)
: typeLoc(TypeLoc::withoutLoc(contextualTy)), purpose(purpose) {}
ContextualTypeInfo(TypeLoc typeLoc, ContextualTypePurpose purpose)
: typeLoc(typeLoc), purpose(purpose) {}
Type getType() const { return typeLoc.getType(); }
};
/// Describes the kind of constraint placed on one or more types.
enum class ConstraintKind : char {
/// The two types must be bound to the same type. This is the only