@@ -111,10 +111,24 @@ class PolymorphicConvention {
111
111
FulfillmentMap Fulfillments;
112
112
113
113
GenericSignature::RequiredProtocols getRequiredProtocols (Type t) {
114
+ // FIXME: We need to rework this to use archetypes instead of interface
115
+ // types, or fix the bad interaction between interface type substitution
116
+ // and concretized conformance requirements. Then we can remove the hack
117
+ // from getReducedType() to handle this case, and also stop calling
118
+ // getReducedType() here.
119
+ t = Generics.getReducedType (t);
120
+ if (!t->isTypeParameter ())
121
+ return {};
122
+
114
123
return Generics->getRequiredProtocols (t);
115
124
}
116
125
117
126
CanType getSuperclassBound (Type t) {
127
+ // See above.
128
+ t = Generics.getReducedType (t);
129
+ if (!t->isTypeParameter ())
130
+ return CanType ();
131
+
118
132
if (auto superclassTy = Generics->getSuperclassBound (t))
119
133
return superclassTy->getCanonicalType ();
120
134
return CanType ();
@@ -143,8 +157,6 @@ class PolymorphicConvention {
143
157
}
144
158
145
159
private:
146
- void initGenerics ();
147
-
148
160
template <typename ...Args>
149
161
void considerNewTypeSource (IsExact_t isExact, MetadataSource::Kind kind,
150
162
CanType type, Args... args);
@@ -199,9 +211,8 @@ class PolymorphicConvention {
199
211
PolymorphicConvention::PolymorphicConvention (IRGenModule &IGM,
200
212
CanSILFunctionType fnType,
201
213
bool considerParameterSources = true )
202
- : IGM(IGM), M(*IGM.getSwiftModule()), FnType(fnType){
203
- initGenerics ();
204
-
214
+ : IGM(IGM), M(*IGM.getSwiftModule()), FnType(fnType),
215
+ Generics(fnType->getInvocationGenericSignature ()) {
205
216
auto rep = fnType->getRepresentation ();
206
217
207
218
if (fnType->isPseudogeneric ()) {
@@ -249,11 +260,8 @@ PolymorphicConvention::PolymorphicConvention(IRGenModule &IGM,
249
260
250
261
void PolymorphicConvention::addPseudogenericFulfillments () {
251
262
enumerateRequirements ([&](GenericRequirement reqt) {
252
- auto archetype = Generics.getGenericEnvironment ()
253
- ->mapTypeIntoContext (reqt.getTypeParameter ())
254
- ->getAs <ArchetypeType>();
255
- assert (archetype && " did not get an archetype by mapping param?" );
256
- auto erasedTypeParam = archetype->getExistentialType ()->getCanonicalType ();
263
+ auto erasedTypeParam = Generics->getExistentialType (reqt.getTypeParameter ())
264
+ ->getCanonicalType ();
257
265
Sources.emplace_back (MetadataSource::Kind::ErasedTypeMetadata,
258
266
reqt.getTypeParameter (), erasedTypeParam);
259
267
@@ -319,10 +327,6 @@ enumerateUnfulfilledRequirements(const RequirementCallback &callback) {
319
327
});
320
328
}
321
329
322
- void PolymorphicConvention::initGenerics () {
323
- Generics = FnType->getInvocationGenericSignature ();
324
- }
325
-
326
330
template <typename ...Args>
327
331
void PolymorphicConvention::considerNewTypeSource (IsExact_t isExact,
328
332
MetadataSource::Kind kind,
0 commit comments