Skip to content

Commit f2bef2d

Browse files
committed
[GSB] Generalize rewrite paths to support “absolute” paths.
Previously, the term rewriting logic for same-type constraints was only able to express “relative” rewrites, where the base of the type being rewritten (i.e., the generic type at the root) is unchanged. This meant that we were unable to capture same-type constraints such as “T == U” or “T.Foo == T” within the rewriting system. Separate out the notion of a rewrite path and extend it with an optional new base. When we’re simplifying a term and we encounter one of these replacements, the whole type from the base up through the last-matched path component gets replaced with the replacement path.
1 parent a419221 commit f2bef2d

File tree

2 files changed

+347
-176
lines changed

2 files changed

+347
-176
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -809,21 +809,11 @@ class GenericSignatureBuilder {
809809
/// Determine whether the two given types are in the same equivalence class.
810810
bool areInSameEquivalenceClass(Type type1, Type type2);
811811

812-
/// Simplify the given type, which is described by a base parameter
813-
/// followed by a sequence of associated types.
814-
///
815-
/// \param path is updated to describe the best path from the given base
816-
/// to the same equivalence class.
817-
///
818-
/// \returns true if the path was simplified at all.
819-
bool simplifyType(GenericParamKey base,
820-
SmallVectorImpl<AssociatedTypeDecl *> &path);
821-
822-
/// Simplify the given type down to its anchor.
812+
/// Simplify the given dependent type down to its canonical representation.
823813
///
824814
/// \returns null if the type involved dependent member types that
825815
/// don't have associated types.
826-
Type simplifyType(Type type);
816+
Type getCanonicalTypeParameter(Type type);
827817

828818
/// Verify the correctness of the given generic signature.
829819
///

0 commit comments

Comments
 (0)