@@ -115,11 +115,12 @@ void PropertyBag::dump(llvm::raw_ostream &out) const {
115115 out << " layout: " << Layout;
116116 }
117117
118- if (Superclass) {
119- out << " superclass: " << *Superclass;
118+ if (hasSuperclassBound ()) {
119+ const auto &superclassReq = getSuperclassRequirement ();
120+ out << " superclass: " << *superclassReq.SuperclassType ;
120121 }
121122
122- if (ConcreteType ) {
123+ if (isConcreteType () ) {
123124 out << " concrete_type: " << *ConcreteType;
124125 }
125126
@@ -154,8 +155,10 @@ Type PropertyBag::getSuperclassBound(
154155 const MutableTerm &lookupTerm,
155156 const PropertyMap &map) const {
156157 MutableTerm prefix = getPrefixAfterStrippingKey (lookupTerm);
157- return map.getTypeFromSubstitutionSchema (Superclass->getConcreteType (),
158- Superclass->getSubstitutions (),
158+
159+ const auto &req = getSuperclassRequirement ();
160+ return map.getTypeFromSubstitutionSchema (req.SuperclassType ->getConcreteType (),
161+ req.SuperclassType ->getSubstitutions (),
159162 genericParams, prefix);
160163}
161164
@@ -199,17 +202,23 @@ void PropertyBag::copyPropertiesFrom(const PropertyBag *next,
199202 // T := UV should have substitutions {UX1, ..., UXn}.
200203 MutableTerm prefix (Key.begin (), Key.begin () + prefixLength);
201204
202- if (next->Superclass ) {
203- Superclass = next->Superclass ->prependPrefixToConcreteSubstitutions (
204- prefix, ctx);
205- SuperclassRule = next->SuperclassRule ;
206- }
207-
208205 if (next->ConcreteType ) {
209206 ConcreteType = next->ConcreteType ->prependPrefixToConcreteSubstitutions (
210207 prefix, ctx);
211208 ConcreteTypeRule = next->ConcreteTypeRule ;
212209 }
210+
211+ // Copy over class hierarchy information.
212+ SuperclassDecl = next->SuperclassDecl ;
213+ if (!next->Superclasses .empty ()) {
214+ Superclasses = next->Superclasses ;
215+
216+ for (auto &pair : Superclasses) {
217+ pair.second .SuperclassType =
218+ pair.second .SuperclassType ->prependPrefixToConcreteSubstitutions (
219+ prefix, ctx);
220+ }
221+ }
213222}
214223
215224void PropertyBag::verify (const RewriteSystem &system) const {
@@ -221,11 +230,18 @@ void PropertyBag::verify(const RewriteSystem &system) const {
221230 assert (symbol.getProtocol () == ConformsTo[i]);
222231 }
223232
224- // FIXME: Once unification introduces new rules, add asserts requiring
225- // that the layout, superclass and concrete type symbols match, as above
233+ // FIXME: Add asserts requiring that the layout, superclass and
234+ // concrete type symbols match, as above
226235 assert (!Layout.isNull () == LayoutRule.hasValue ());
227- assert (Superclass.hasValue () == SuperclassRule.hasValue ());
228236 assert (ConcreteType.hasValue () == ConcreteTypeRule.hasValue ());
237+
238+ assert ((SuperclassDecl == nullptr ) == Superclasses.empty ());
239+ for (const auto &pair : Superclasses) {
240+ const auto &req = pair.second ;
241+ assert (req.SuperclassType .hasValue ());
242+ assert (req.SuperclassRule .hasValue ());
243+ }
244+
229245#endif
230246}
231247
0 commit comments