File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -4314,16 +4314,29 @@ case TypeKind::Id:
4314
4314
}
4315
4315
4316
4316
case TypeKind::SILBox: {
4317
+ bool changed = false ;
4318
+ auto boxTy = cast<SILBoxType>(base);
4317
4319
#ifndef NDEBUG
4318
4320
// This interface isn't suitable for updating the substitution map in a
4319
4321
// generic SILBox.
4320
- auto boxTy = cast<SILBoxType>(base);
4321
4322
for (Type type : boxTy->getSubstitutions ().getReplacementTypes ()) {
4322
4323
assert (type->isEqual (type.transformRec (fn))
4323
- && " SILBoxType can't be transformed" );
4324
+ && " SILBoxType substitutions can't be transformed" );
4324
4325
}
4325
4326
#endif
4326
- return base;
4327
+ SmallVector<SILField, 4 > newFields;
4328
+ auto *l = boxTy->getLayout ();
4329
+ for (auto f : l->getFields ()) {
4330
+ auto fieldTy = f.getLoweredType ();
4331
+ auto transformed = fieldTy.transformRec (fn)->getCanonicalType ();
4332
+ changed |= fieldTy != transformed;
4333
+ newFields.push_back (SILField (transformed, f.isMutable ()));
4334
+ }
4335
+ boxTy = SILBoxType::get (Ptr->getASTContext (),
4336
+ SILLayout::get (Ptr->getASTContext (),
4337
+ l->getGenericSignature (), newFields),
4338
+ boxTy->getSubstitutions ());
4339
+ return boxTy;
4327
4340
}
4328
4341
4329
4342
case TypeKind::SILFunction: {
Original file line number Diff line number Diff line change @@ -637,8 +637,8 @@ bool SILType::isDifferentiable(SILModule &M) const {
637
637
638
638
Type
639
639
TypeBase::replaceSubstitutedSILFunctionTypesWithUnsubstituted (SILModule &M) const {
640
- return Type (const_cast <TypeBase*>(this )).transform ([&](Type t) -> Type {
641
- if (auto f = t->getAs <SILFunctionType>()) {
640
+ return Type (const_cast <TypeBase *>(this )).transform ([&](Type t) -> Type {
641
+ if (auto * f = t->getAs <SILFunctionType>()) {
642
642
auto sft = f->getUnsubstitutedType (M);
643
643
644
644
// Also eliminate substituted function types in the arguments, yields,
You can’t perform that action at this time.
0 commit comments