Skip to content

Commit cbf4dce

Browse files
committed
IRGen: Clean up substOpaqueTypesWithUnderlyingTypes() wrappers
1 parent cbb2374 commit cbf4dce

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

lib/IRGen/MetadataRequest.cpp

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,10 @@ CanType IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type) {
528528
// Substitute away opaque types whose underlying types we're allowed to
529529
// assume are constant.
530530
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);
538535
}
539536

540537
return type;
@@ -545,13 +542,12 @@ SILType IRGenModule::substOpaqueTypesWithUnderlyingTypes(
545542
// Substitute away opaque types whose underlying types we're allowed to
546543
// assume are constant.
547544
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());
555551
}
556552

557553
return type;
@@ -563,15 +559,12 @@ IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type,
563559
// Substitute away opaque types whose underlying types we're allowed to
564560
// assume are constant.
565561
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));
575568
}
576569

577570
return std::make_pair(type, conformance);

0 commit comments

Comments
 (0)