Skip to content

Commit ce83c8b

Browse files
authored
Merge pull request #14454 from DougGregor/gsb-term-rewriting
[GSB] Term rewriting for same-type constraints
2 parents 3798bed + 1e7562a commit ce83c8b

File tree

2 files changed

+807
-99
lines changed

2 files changed

+807
-99
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,13 @@ class GenericSignatureBuilder {
258258
Type getTypeInContext(GenericSignatureBuilder &builder,
259259
GenericEnvironment *genericEnv);
260260

261-
/// Dump a debugging representation of this equivalence class.
262-
void dump(llvm::raw_ostream &out) const;
261+
/// Dump a debugging representation of this equivalence class,
262+
void dump(llvm::raw_ostream &out,
263+
GenericSignatureBuilder *builder = nullptr) const;
263264

264-
LLVM_ATTRIBUTE_DEPRECATED(void dump() const,
265-
"only for use in the debugger");
265+
LLVM_ATTRIBUTE_DEPRECATED(
266+
void dump(GenericSignatureBuilder *builder = nullptr) const,
267+
"only for use in the debugger");
266268

267269
/// Caches.
268270

@@ -271,9 +273,8 @@ class GenericSignatureBuilder {
271273
/// The cached anchor itself.
272274
Type anchor;
273275

274-
/// The number of members of the equivalence class when the archetype
275-
/// anchor was cached.
276-
unsigned numMembers;
276+
/// The generation at which the anchor was last computed.
277+
unsigned lastGeneration;
277278
} archetypeAnchorCache;
278279

279280
/// Describes a cached nested type.
@@ -444,6 +445,11 @@ class GenericSignatureBuilder {
444445
/// Note that we have added the nested type nestedPA
445446
void addedNestedType(PotentialArchetype *nestedPA);
446447

448+
/// Add a rewrite rule for a same-type constraint between the given
449+
/// types.
450+
void addSameTypeRewriteRule(PotentialArchetype *type1,
451+
PotentialArchetype *type2);
452+
447453
/// \brief Add a new conformance requirement specifying that the given
448454
/// potential archetypes are equivalent.
449455
ConstraintResult addSameTypeRequirementBetweenArchetypes(
@@ -802,6 +808,12 @@ class GenericSignatureBuilder {
802808
/// Determine whether the two given types are in the same equivalence class.
803809
bool areInSameEquivalenceClass(Type type1, Type type2);
804810

811+
/// Simplify the given dependent type down to its canonical representation.
812+
///
813+
/// \returns null if the type involved dependent member types that
814+
/// don't have associated types.
815+
Type getCanonicalTypeParameter(Type type);
816+
805817
/// Verify the correctness of the given generic signature.
806818
///
807819
/// This routine will test that the given generic signature is both minimal

0 commit comments

Comments
 (0)