Skip to content

Commit 7916ed9

Browse files
committed
Sema: Move DeclReferenceType to PreparedOverload.h
1 parent f7a5523 commit 7916ed9

File tree

4 files changed

+34
-29
lines changed

4 files changed

+34
-29
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ namespace constraints {
6464

6565
class ConstraintSystem;
6666
class SyntacticElementTarget;
67+
68+
// PreparedOverload.h
69+
struct DeclReferenceType;
6770
struct PreparedOverload;
6871
struct PreparedOverloadBuilder;
6972

@@ -2144,34 +2147,6 @@ struct ClosureIsolatedByPreconcurrency {
21442147
bool operator()(const ClosureExpr *expr) const;
21452148
};
21462149

2147-
/// Describes the type produced when referencing a declaration.
2148-
struct DeclReferenceType {
2149-
/// The "opened" type, which is the type of the declaration where any
2150-
/// generic parameters have been replaced with type variables.
2151-
///
2152-
/// The mapping from generic parameters to type variables will have been
2153-
/// recorded by \c recordOpenedTypes when this type is produced.
2154-
Type openedType;
2155-
2156-
/// The opened type, after performing contextual type adjustments such as
2157-
/// removing concurrency-related annotations for a `@preconcurrency`
2158-
/// operation.
2159-
Type adjustedOpenedType;
2160-
2161-
/// The type of the reference, based on the original opened type. This is the
2162-
/// type that the expression used to form the declaration reference would
2163-
/// have if no adjustments had been applied.
2164-
Type referenceType;
2165-
2166-
/// The type of the reference, which is the adjusted opened type after
2167-
/// (e.g.) applying the base of a member access. This is the type of the
2168-
/// expression used to form the declaration reference.
2169-
Type adjustedReferenceType;
2170-
2171-
/// The type that could be thrown by accessing this declaration.
2172-
Type thrownErrorTypeOnAccess;
2173-
};
2174-
21752150
/// Describes a system of constraints on type variables, the
21762151
/// solution of which assigns concrete types to each of the type variables.
21772152
/// Constraint systems are typically generated given an (untyped) expression.

include/swift/Sema/PreparedOverload.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@ namespace constraints {
2727
class ConstraintLocatorBuilder;
2828
class ConstraintSystem;
2929

30+
/// Describes the type produced when referencing a declaration.
31+
struct DeclReferenceType {
32+
/// The "opened" type, which is the type of the declaration where any
33+
/// generic parameters have been replaced with type variables.
34+
///
35+
/// The mapping from generic parameters to type variables will have been
36+
/// recorded by \c recordOpenedTypes when this type is produced.
37+
Type openedType;
38+
39+
/// The opened type, after performing contextual type adjustments such as
40+
/// removing concurrency-related annotations for a `@preconcurrency`
41+
/// operation.
42+
Type adjustedOpenedType;
43+
44+
/// The type of the reference, based on the original opened type. This is the
45+
/// type that the expression used to form the declaration reference would
46+
/// have if no adjustments had been applied.
47+
Type referenceType;
48+
49+
/// The type of the reference, which is the adjusted opened type after
50+
/// (e.g.) applying the base of a member access. This is the type of the
51+
/// expression used to form the declaration reference.
52+
Type adjustedReferenceType;
53+
54+
/// The type that could be thrown by accessing this declaration.
55+
Type thrownErrorTypeOnAccess;
56+
};
57+
3058
/// Describes a dependent type that has been opened to a particular type
3159
/// variable.
3260
using OpenedType = std::pair<GenericTypeParamType *, TypeVariableType *>;
@@ -101,6 +129,7 @@ struct PreparedOverload {
101129
};
102130

103131
ArrayRef<Change> Changes;
132+
DeclReferenceType DeclType;
104133
};
105134

106135
struct PreparedOverloadBuilder {

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "swift/Basic/StringExtras.h"
6363
#include "swift/ClangImporter/ClangModule.h"
6464
#include "swift/Sema/IDETypeChecking.h"
65+
#include "swift/Sema/PreparedOverload.h"
6566
#include "swift/Serialization/SerializedModuleLoader.h"
6667
#include "llvm/ADT/SmallString.h"
6768
#include "llvm/ADT/Statistic.h"

lib/Sema/TypeOfReference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
26172617

26182618
if (enablePreparedOverloads) {
26192619
PreparingOverload = false;
2620-
PreparedOverload result{preparedOverload.Changes};
2620+
PreparedOverload result{preparedOverload.Changes, declRefType};
26212621
replayChanges(locator, result);
26222622
}
26232623

0 commit comments

Comments
 (0)