6060using namespace swift ;
6161using namespace rewriting ;
6262
63- // / This papers over a behavioral difference between
64- // / GenericSignature::getRequiredProtocols() and ArchetypeType::getConformsTo();
65- // / the latter drops any protocols to which the superclass requirement
66- // / conforms to concretely.
67- llvm::TinyPtrVector<const ProtocolDecl *>
68- PropertyBag::getConformsToExcludingSuperclassConformances () const {
69- llvm::TinyPtrVector<const ProtocolDecl *> result;
70-
71- if (SuperclassConformances.empty ()) {
72- result = ConformsTo;
73- return result;
74- }
75-
76- // The conformances in SuperclassConformances should appear in the same order
77- // as the protocols in ConformsTo.
78- auto conformanceIter = SuperclassConformances.begin ();
79-
80- for (const auto *proto : ConformsTo) {
81- if (conformanceIter == SuperclassConformances.end ()) {
82- result.push_back (proto);
83- continue ;
84- }
85-
86- if (proto == (*conformanceIter)->getProtocol ()) {
87- ++conformanceIter;
88- continue ;
89- }
90-
91- result.push_back (proto);
92- }
93-
94- assert (conformanceIter == SuperclassConformances.end ());
95- return result;
96- }
97-
9863void PropertyBag::dump (llvm::raw_ostream &out) const {
9964 out << Key << " => {" ;
10065
@@ -205,30 +170,41 @@ void PropertyBag::copyPropertiesFrom(const PropertyBag *next,
205170 if (next->ConcreteType ) {
206171 ConcreteType = next->ConcreteType ->prependPrefixToConcreteSubstitutions (
207172 prefix, ctx);
208- ConcreteTypeRule = next->ConcreteTypeRule ;
173+ ConcreteTypeRules = next->ConcreteTypeRules ;
174+ for (auto &pair : ConcreteTypeRules) {
175+ pair.first = pair.first .prependPrefixToConcreteSubstitutions (
176+ prefix, ctx);
177+ }
209178 }
210179
211180 // Copy over class hierarchy information.
212181 SuperclassDecl = next->SuperclassDecl ;
213182 if (!next->Superclasses .empty ()) {
214183 Superclasses = next->Superclasses ;
215184
216- for (auto &pair : Superclasses) {
217- pair .second .SuperclassType =
218- pair .second .SuperclassType ->prependPrefixToConcreteSubstitutions (
185+ for (auto &req : Superclasses) {
186+ req .second .SuperclassType =
187+ req .second .SuperclassType ->prependPrefixToConcreteSubstitutions (
219188 prefix, ctx);
189+ for (auto &pair : req.second .SuperclassRules ) {
190+ pair.first = pair.first .prependPrefixToConcreteSubstitutions (
191+ prefix, ctx);
192+ }
220193 }
221194 }
222195}
223196
224197Symbol PropertyBag::concretelySimplifySubstitution (const MutableTerm &mutTerm,
225198 RewriteContext &ctx,
226199 RewritePath *path) const {
200+ assert (!ConcreteTypeRules.empty ());
201+ auto &pair = ConcreteTypeRules.front ();
202+
227203 // The property map entry might apply to a suffix of the substitution
228204 // term, so prepend the appropriate prefix to its own substitutions.
229205 auto prefix = getPrefixAfterStrippingKey (mutTerm);
230206 auto concreteSymbol =
231- ConcreteType-> prependPrefixToConcreteSubstitutions (
207+ pair. first . prependPrefixToConcreteSubstitutions (
232208 prefix, ctx);
233209
234210 // If U.V is the substitution term and V is the property map key,
@@ -238,7 +214,7 @@ Symbol PropertyBag::concretelySimplifySubstitution(const MutableTerm &mutTerm,
238214 if (path) {
239215 path->add (RewriteStep::forRewriteRule (/* startOffset=*/ prefix.size (),
240216 /* endOffset=*/ 0 ,
241- /* ruleID=*/ *ConcreteTypeRule ,
217+ /* ruleID=*/ pair. second ,
242218 /* inverse=*/ true ));
243219
244220 if (!prefix.empty ()) {
@@ -263,13 +239,13 @@ void PropertyBag::verify(const RewriteSystem &system) const {
263239 // FIXME: Add asserts requiring that the layout, superclass and
264240 // concrete type symbols match, as above
265241 assert (!Layout.isNull () == LayoutRule.hasValue ());
266- assert (ConcreteType.hasValue () == ConcreteTypeRule. hasValue ());
242+ assert (ConcreteType.hasValue () == !ConcreteTypeRules. empty ());
267243
268244 assert ((SuperclassDecl == nullptr ) == Superclasses.empty ());
269245 for (const auto &pair : Superclasses) {
270246 const auto &req = pair.second ;
271247 assert (req.SuperclassType .hasValue ());
272- assert (req.SuperclassRule . hasValue ());
248+ assert (! req.SuperclassRules . empty ());
273249 }
274250
275251#endif
@@ -396,8 +372,7 @@ void PropertyMap::buildPropertyMap() {
396372
397373 for (const auto &rule : System.getRules ()) {
398374 if (rule.isLHSSimplified () ||
399- rule.isRHSSimplified () ||
400- rule.isSubstitutionSimplified ())
375+ rule.isRHSSimplified ())
401376 continue ;
402377
403378 // Identity conformances ([P].[P] => [P]) are permanent rules, but we
0 commit comments