AST: Pass SubstFlags::PreservePackExpansionLevel in a few more places

This commit is contained in:
Slava Pestov
2024-04-04 14:56:13 -04:00
parent 3630ce7130
commit 082246094b
3 changed files with 12 additions and 5 deletions

View File

@@ -1633,7 +1633,9 @@ SwiftDeclCollector::constructTypeNode(Type T, TypeInitInfo Info) {
ReplaceOpaqueTypesWithUnderlyingTypes replacer( ReplaceOpaqueTypesWithUnderlyingTypes replacer(
/*inContext=*/nullptr, ResilienceExpansion::Maximal, /*inContext=*/nullptr, ResilienceExpansion::Maximal,
/*isWholeModuleContext=*/false); /*isWholeModuleContext=*/false);
T = T.subst(replacer, replacer, SubstFlags::SubstituteOpaqueArchetypes) T = T.subst(replacer, replacer,
SubstFlags::SubstituteOpaqueArchetypes |
SubstFlags::PreservePackExpansionLevel)
->getCanonicalType(); ->getCanonicalType();
} }
} }

View File

@@ -1016,7 +1016,9 @@ static Type substOpaqueTypesWithUnderlyingTypesRec(
llvm::DenseSet<ReplaceOpaqueTypesWithUnderlyingTypes::SeenDecl> &decls) { llvm::DenseSet<ReplaceOpaqueTypesWithUnderlyingTypes::SeenDecl> &decls) {
ReplaceOpaqueTypesWithUnderlyingTypes replacer(inContext, contextExpansion, ReplaceOpaqueTypesWithUnderlyingTypes replacer(inContext, contextExpansion,
isWholeModuleContext, decls); isWholeModuleContext, decls);
return ty.subst(replacer, replacer, SubstFlags::SubstituteOpaqueArchetypes); return ty.subst(replacer, replacer,
SubstFlags::SubstituteOpaqueArchetypes |
SubstFlags::PreservePackExpansionLevel);
} }
/// Checks that \p dc has access to \p ty for the purposes of an opaque /// Checks that \p dc has access to \p ty for the purposes of an opaque
@@ -1169,7 +1171,8 @@ static ProtocolConformanceRef substOpaqueTypesWithUnderlyingTypesRec(
ReplaceOpaqueTypesWithUnderlyingTypes replacer(inContext, contextExpansion, ReplaceOpaqueTypesWithUnderlyingTypes replacer(inContext, contextExpansion,
isWholeModuleContext, decls); isWholeModuleContext, decls);
return ref.subst(origType, replacer, replacer, return ref.subst(origType, replacer, replacer,
SubstFlags::SubstituteOpaqueArchetypes); SubstFlags::SubstituteOpaqueArchetypes |
SubstFlags::PreservePackExpansionLevel);
} }
ProtocolConformanceRef swift::substOpaqueTypesWithUnderlyingTypes( ProtocolConformanceRef swift::substOpaqueTypesWithUnderlyingTypes(

View File

@@ -4800,14 +4800,16 @@ static bool areABICompatibleParamsOrReturns(SILType a, SILType b,
if (aa.getASTType()->hasOpaqueArchetype()) if (aa.getASTType()->hasOpaqueArchetype())
opaqueTypesSubstituted = aa.subst(inFunction->getModule(), replacer, opaqueTypesSubstituted = aa.subst(inFunction->getModule(), replacer,
replacer, CanGenericSignature(), replacer, CanGenericSignature(),
SubstFlags::SubstituteOpaqueArchetypes); SubstFlags::SubstituteOpaqueArchetypes |
SubstFlags::PreservePackExpansionLevel);
auto opaqueTypesSubstituted2 = bb; auto opaqueTypesSubstituted2 = bb;
if (bb.getASTType()->hasOpaqueArchetype()) if (bb.getASTType()->hasOpaqueArchetype())
opaqueTypesSubstituted2 = opaqueTypesSubstituted2 =
bb.subst(inFunction->getModule(), replacer, replacer, bb.subst(inFunction->getModule(), replacer, replacer,
CanGenericSignature(), CanGenericSignature(),
SubstFlags::SubstituteOpaqueArchetypes); SubstFlags::SubstituteOpaqueArchetypes |
SubstFlags::PreservePackExpansionLevel);
if (opaqueTypesSubstituted == opaqueTypesSubstituted2) if (opaqueTypesSubstituted == opaqueTypesSubstituted2)
continue; continue;
} }