@@ -68,59 +68,10 @@ Substitution Substitution::subst(TypeSubstitutionFn subs,
68
68
substConformances.reserve (Conformance.size ());
69
69
70
70
for (auto c : Conformance) {
71
- // If we have a concrete conformance, we need to substitute the
72
- // conformance to apply to the new type.
73
- if (c.isConcrete ()) {
74
- auto substC = c.getConcrete ()->subst (substReplacement,
75
- subs, conformances);
76
- substConformances.push_back (ProtocolConformanceRef (substC));
77
- if (c != substConformances.back ())
78
- conformancesChanged = true ;
79
- continue ;
80
- }
81
-
82
- // Otherwise, we may need to fill in the conformance.
83
- ProtocolDecl *proto = c.getAbstract ();
84
- Optional<ProtocolConformanceRef> conformance;
85
-
86
- // If the original type was an archetype, check the conformance map.
87
- if (Replacement->is <SubstitutableType>()
88
- || Replacement->is <DependentMemberType>()) {
89
- conformance = conformances (Replacement->getCanonicalType (),
90
- substReplacement,
91
- proto->getDeclaredType ());
92
- }
93
-
94
- // If that didn't find anything, we can still synthesize AnyObject
95
- // conformances from thin air. FIXME: gross.
96
- if (!conformance &&
97
- proto->isSpecificProtocol (KnownProtocolKind::AnyObject)) {
98
- auto archetype =
99
- dyn_cast<ArchetypeType>(substReplacement->getCanonicalType ());
100
- // If classDecl is not nullptr, it is a concrete class.
101
- auto classDecl = substReplacement->getClassOrBoundGenericClass ();
102
- if (!classDecl && archetype->getSuperclass ()) {
103
- // Replacement type is an archetype with a superclass constraint.
104
- classDecl = archetype->getSuperclass ()->getClassOrBoundGenericClass ();
105
- assert (classDecl);
106
- }
107
- if (classDecl) {
108
- // Create a concrete conformance based on the conforming class.
109
- SmallVector<ProtocolConformance *, 1 > lookupResults;
110
- classDecl->lookupConformance (classDecl->getParentModule (), proto,
111
- lookupResults);
112
- conformance = ProtocolConformanceRef (lookupResults.front ());
113
- } else if (archetype && archetype->requiresClass ()) {
114
- // Replacement type is an archetype with a class constraint.
115
- // Create an abstract conformance.
116
- conformance = ProtocolConformanceRef (proto);
117
- }
118
- }
119
-
120
- assert (conformance);
121
- if (conformance->isConcrete ())
71
+ auto newC = c.subst (Replacement, subs, conformances);
72
+ if (c != newC)
122
73
conformancesChanged = true ;
123
- substConformances.push_back (*conformance );
74
+ substConformances.push_back (newC );
124
75
}
125
76
assert (substConformances.size () == Conformance.size ());
126
77
0 commit comments