Skip to content

Commit d03ff29

Browse files
committed
RequirementMachine: Protocol atoms order before associated type atoms
If you have a same-type requirement like 'Self.Foo == Self' inside a protocol P, we add a rewrite rule: [P].Foo => [P] Simplification turns this into [P:Foo] => [P] Previously, the order was backwards so we would end up with [P] => [P:Foo] Which would mess up the conformance information in the equivalence class map.
1 parent e4faf73 commit d03ff29

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

lib/AST/RequirementMachine/RewriteSystem.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,15 @@ Atom Atom::forConcreteType(CanType type, ArrayRef<Term> substitutions,
393393

394394
/// Linear order on atoms.
395395
///
396-
/// First, we order different kinds as follows:
396+
/// First, we order different kinds as follows, from smallest to largest:
397397
///
398-
/// AssociatedType < GenericParam < Name < Protocol < Layout
398+
/// - Protocol
399+
/// - AssociatedType
400+
/// - GenericParam
401+
/// - Name
402+
/// - Layout
403+
/// - Superclass
404+
/// - ConcreteType
399405
///
400406
/// Then we break ties when both atoms have the same kind as follows:
401407
///

lib/AST/RequirementMachine/RewriteSystem.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ class Term;
7272
class Atom final {
7373
public:
7474
enum class Kind : uint8_t {
75+
//////
76+
////// Special atom kind that is both type-like and property-like:
77+
//////
78+
79+
/// When appearing at the start of a term, denotes a nested
80+
/// type of a protocol 'Self' type.
81+
///
82+
/// When appearing at the end of a term, denotes that the
83+
/// term's type conforms to the protocol.
84+
Protocol,
85+
7586
//////
7687
////// "Type-like" atom kinds:
7788
//////
@@ -93,13 +104,6 @@ class Atom final {
93104
////// "Fact-like" atom kinds:
94105
//////
95106

96-
/// When appearing at the start of a term, denotes a nested
97-
/// type of a protocol 'Self' type.
98-
///
99-
/// When appearing at the end of a term, denotes that the
100-
/// term's type conforms to the protocol.
101-
Protocol,
102-
103107
/// When appearing at the end of a term, denotes that the
104108
/// term's type satisfies the layout constraint.
105109
Layout,

0 commit comments

Comments
 (0)