@@ -177,96 +177,6 @@ Type SILFunction::mapTypeIntoContext(Type type) const {
177
177
type);
178
178
}
179
179
180
- namespace {
181
- template <typename SubstFn>
182
- struct SubstDependentSILType
183
- : CanTypeVisitor<SubstDependentSILType<SubstFn>, CanType>
184
- {
185
- SILModule &M;
186
- SubstFn Subst;
187
-
188
- SubstDependentSILType (SILModule &M, SubstFn Subst)
189
- : M(M), Subst(std::move(Subst))
190
- {}
191
-
192
- using super = CanTypeVisitor<SubstDependentSILType<SubstFn>, CanType>;
193
- using super::visit;
194
-
195
- CanType visitDependentMemberType (CanDependentMemberType t) {
196
- // If a dependent member type appears in lowered position, we need to lower
197
- // its context substitution against the associated type's abstraction
198
- // pattern.
199
- CanType astTy = Subst (t);
200
- auto origTy = AbstractionPattern::getOpaque ();
201
-
202
- return M.Types .getLoweredType (origTy, astTy)
203
- .getSwiftRValueType ();
204
- }
205
-
206
- CanType visitTupleType (CanTupleType t) {
207
- // Dependent members can appear in lowered position inside tuples.
208
-
209
- SmallVector<TupleTypeElt, 4 > elements;
210
-
211
- for (auto &elt : t->getElements ())
212
- elements.push_back (elt.getWithType (visit (CanType (elt.getType ()))));
213
-
214
- return TupleType::get (elements, t->getASTContext ())
215
- ->getCanonicalType ();
216
- }
217
-
218
- CanType visitSILFunctionType (CanSILFunctionType t) {
219
- // Dependent members can appear in lowered position inside SIL functions.
220
-
221
- SmallVector<SILParameterInfo, 4 > params;
222
- for (auto ¶m : t->getParameters ())
223
- params.push_back (param.map ([&](CanType pt) -> CanType {
224
- return visit (pt);
225
- }));
226
-
227
- SmallVector<SILResultInfo, 4 > results;
228
- for (auto &result : t->getAllResults ())
229
- results.push_back (result.map ([&](CanType pt) -> CanType {
230
- return visit (pt);
231
- }));
232
-
233
- Optional<SILResultInfo> errorResult;
234
- if (t->hasErrorResult ()) {
235
- errorResult = t->getErrorResult ().map ([&](CanType elt) -> CanType {
236
- return visit (elt);
237
- });
238
- }
239
-
240
- return SILFunctionType::get (t->getGenericSignature (),
241
- t->getExtInfo (),
242
- t->getCalleeConvention (),
243
- params, results, errorResult,
244
- t->getASTContext ());
245
- }
246
-
247
- CanType visitType (CanType t) {
248
- // Other types get substituted into context normally.
249
- return Subst (t);
250
- }
251
- };
252
-
253
- template <typename SubstFn>
254
- SILType doSubstDependentSILType (SILModule &M,
255
- SubstFn Subst,
256
- SILType t) {
257
- CanType result = SubstDependentSILType<SubstFn>(M, std::move (Subst))
258
- .visit (t.getSwiftRValueType ());
259
- return SILType::getPrimitiveType (result, t.getCategory ());
260
- }
261
-
262
- } // end anonymous namespace
263
-
264
- SILType ArchetypeBuilder::substDependentType (SILModule &M, SILType type) {
265
- return doSubstDependentSILType (M,
266
- [&](CanType t) { return substDependentType (t)->getCanonicalType (); },
267
- type);
268
- }
269
-
270
180
SILType SILFunction::mapTypeIntoContext (SILType type) const {
271
181
if (getGenericEnvironment () == nullptr )
272
182
return type;
0 commit comments