@@ -192,50 +192,31 @@ void RequirementBuilder::addRequirementRules(ArrayRef<unsigned> rules) {
192192 prop->getLayoutConstraint ());
193193 return ;
194194
195- case Symbol::Kind::Superclass: {
196- // Requirements containing unresolved name symbols originate from
197- // invalid code and should not appear in the generic signature.
198- for (auto term : prop->getSubstitutions ()) {
199- if (term.containsUnresolvedSymbols ())
200- return ;
201- }
202-
203- Type superclassType = Map.getTypeFromSubstitutionSchema (
204- prop->getConcreteType (),
205- prop->getSubstitutions (),
206- GenericParams, MutableTerm ());
207- if (rule.isRecursive ())
208- superclassType = replaceTypeParametersWithErrorTypes (superclassType);
209-
210- if (ReconstituteSugar)
211- superclassType = superclassType->reconstituteSugar (/* recursive=*/ true );
212-
213- Reqs.emplace_back (RequirementKind::Superclass,
214- subjectType, superclassType);
215- return ;
216- }
217-
195+ case Symbol::Kind::Superclass:
218196 case Symbol::Kind::ConcreteType: {
219- // Requirements containing unresolved name symbols originate from
220- // invalid code and should not appear in the generic signature.
197+ bool containsUnresolvedSymbols = false ;
221198 for (auto term : prop->getSubstitutions ()) {
222- if (term.containsUnresolvedSymbols ())
223- return ;
199+ containsUnresolvedSymbols |= term.containsUnresolvedSymbols ();
224200 }
225201
226202 Type concreteType = Map.getTypeFromSubstitutionSchema (
227203 prop->getConcreteType (),
228204 prop->getSubstitutions (),
229205 GenericParams, MutableTerm ());
230- if (rule.isRecursive ())
206+ if (containsUnresolvedSymbols || rule.isRecursive ())
231207 concreteType = replaceTypeParametersWithErrorTypes (concreteType);
232208
233209 if (ReconstituteSugar)
234210 concreteType = concreteType->reconstituteSugar (/* recursive=*/ true );
235211
236- auto &component = Components[rule.getRHS ()];
237- assert (!component.ConcreteType );
238- component.ConcreteType = concreteType;
212+ if (prop->getKind () == Symbol::Kind::Superclass) {
213+ Reqs.emplace_back (RequirementKind::Superclass,
214+ subjectType, concreteType);
215+ } else {
216+ auto &component = Components[rule.getRHS ()];
217+ assert (!component.ConcreteType );
218+ component.ConcreteType = concreteType;
219+ }
239220 return ;
240221 }
241222
0 commit comments