IRGen: Use getMaximalTypeExpansionContext()

This commit is contained in:
Slava Pestov
2024-04-04 15:59:25 -04:00
parent cbf4dce068
commit 153da37521
2 changed files with 7 additions and 18 deletions

View File

@@ -528,8 +528,7 @@ CanType IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type) {
// Substitute away opaque types whose underlying types we're allowed to
// assume are constant.
if (type->hasOpaqueArchetype()) {
auto context = TypeExpansionContext::maximal(getSwiftModule(),
getSILModule().isWholeModule());
auto context = getMaximalTypeExpansionContext();
return swift::substOpaqueTypesWithUnderlyingTypes(type, context,
/*allowLoweredTypes=*/false);
}
@@ -542,8 +541,7 @@ SILType IRGenModule::substOpaqueTypesWithUnderlyingTypes(
// Substitute away opaque types whose underlying types we're allowed to
// assume are constant.
if (type.getASTType()->hasOpaqueArchetype()) {
auto context = TypeExpansionContext::maximal(getSwiftModule(),
getSILModule().isWholeModule());
auto context = getMaximalTypeExpansionContext();
return SILType::getPrimitiveType(
swift::substOpaqueTypesWithUnderlyingTypes(type.getASTType(), context,
/*allowLoweredTypes=*/true),
@@ -559,8 +557,7 @@ IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type,
// Substitute away opaque types whose underlying types we're allowed to
// assume are constant.
if (type->hasOpaqueArchetype()) {
auto context = TypeExpansionContext::maximal(getSwiftModule(),
getSILModule().isWholeModule());
auto context = getMaximalTypeExpansionContext();
return std::make_pair(
swift::substOpaqueTypesWithUnderlyingTypes(type, context,
/*allowLoweredTypes=*/false),

View File

@@ -10,20 +10,12 @@
// RUN: %target-swift-reflection-dump %t/AssociatedTypeRequirements | %FileCheck %s
// This test is useless and was just relying on a bug where we didn't substitute away
// known opaque return types in non-WMO mode.
// CHECK: ASSOCIATED TYPES:
// CHECK: - AssociatedTypeRequirements.Foo : AssociatedTypeRequirements.myProto
// CHECK-NEXT: typealias PerformReturn = opaque type symbolic reference
// CHECK-NEXT: opaque type symbolic reference
// CHECK-NEXT: (bound_generic_struct AssociatedTypeRequirements.Bar
// CHECK: conformance requirements:
// CHECK-NEXT: AssociatedTypeRequirements.protoA
// CHECK-NEXT: AssociatedTypeRequirements.protoB
// CHECK-NEXT: testModB.testModBProtocol
// CHECK: same-type requirements:
// CHECK-NEXT: A.AssociatedTypeRequirements.protoB.K = Sf (Swift.Float)
// CHECK-NEXT: A.AssociatedTypeRequirements.protoA.T = 8testModB0aB7BStructV (testModB.testModBStruct)
// CHECK-NEXT: typealias PerformReturn = AssociatedTypeRequirements.Bar<testModB.testModBStruct, Swift.Float>
import testModB