@@ -528,13 +528,10 @@ CanType IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type) {
528
528
// Substitute away opaque types whose underlying types we're allowed to
529
529
// assume are constant.
530
530
if (type->hasOpaqueArchetype ()) {
531
- ReplaceOpaqueTypesWithUnderlyingTypes replacer (
532
- getSwiftModule (), ResilienceExpansion::Maximal,
533
- getSILModule ().isWholeModule ());
534
- auto underlyingTy =
535
- type.subst (replacer, replacer, SubstFlags::SubstituteOpaqueArchetypes)
536
- ->getCanonicalType ();
537
- return underlyingTy;
531
+ auto context = TypeExpansionContext::maximal (getSwiftModule (),
532
+ getSILModule ().isWholeModule ());
533
+ return swift::substOpaqueTypesWithUnderlyingTypes (type, context,
534
+ /* allowLoweredTypes=*/ false );
538
535
}
539
536
540
537
return type;
@@ -545,13 +542,12 @@ SILType IRGenModule::substOpaqueTypesWithUnderlyingTypes(
545
542
// Substitute away opaque types whose underlying types we're allowed to
546
543
// assume are constant.
547
544
if (type.getASTType ()->hasOpaqueArchetype ()) {
548
- ReplaceOpaqueTypesWithUnderlyingTypes replacer (
549
- getSwiftModule (), ResilienceExpansion::Maximal,
550
- getSILModule ().isWholeModule ());
551
- auto underlyingTy =
552
- type.subst (getSILModule (), replacer, replacer, genericSig,
553
- SubstFlags::SubstituteOpaqueArchetypes);
554
- return underlyingTy;
545
+ auto context = TypeExpansionContext::maximal (getSwiftModule (),
546
+ getSILModule ().isWholeModule ());
547
+ return SILType::getPrimitiveType (
548
+ swift::substOpaqueTypesWithUnderlyingTypes (type.getASTType (), context,
549
+ /* allowLoweredTypes=*/ true ),
550
+ type.getCategory ());
555
551
}
556
552
557
553
return type;
@@ -563,15 +559,12 @@ IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type,
563
559
// Substitute away opaque types whose underlying types we're allowed to
564
560
// assume are constant.
565
561
if (type->hasOpaqueArchetype ()) {
566
- ReplaceOpaqueTypesWithUnderlyingTypes replacer (
567
- getSwiftModule (), ResilienceExpansion::Maximal,
568
- getSILModule ().isWholeModule ());
569
- auto substConformance = conformance.subst (
570
- type, replacer, replacer, SubstFlags::SubstituteOpaqueArchetypes);
571
- auto underlyingTy =
572
- type.subst (replacer, replacer, SubstFlags::SubstituteOpaqueArchetypes)
573
- ->getCanonicalType ();
574
- return std::make_pair (underlyingTy, substConformance);
562
+ auto context = TypeExpansionContext::maximal (getSwiftModule (),
563
+ getSILModule ().isWholeModule ());
564
+ return std::make_pair (
565
+ swift::substOpaqueTypesWithUnderlyingTypes (type, context,
566
+ /* allowLoweredTypes=*/ false ),
567
+ swift::substOpaqueTypesWithUnderlyingTypes (conformance, type, context));
575
568
}
576
569
577
570
return std::make_pair (type, conformance);
0 commit comments