Skip to content

Commit 072d12a

Browse files
committed
AST: Move substOpaqueTypesWithUnderlyingTypes() to TypeSubstitution.cpp
1 parent 153da37 commit 072d12a

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

lib/AST/Type.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5351,23 +5351,6 @@ Type TypeBase::openAnyExistentialType(OpenedArchetypeType *&opened,
53515351
return opened;
53525352
}
53535353

5354-
CanType swift::substOpaqueTypesWithUnderlyingTypes(CanType ty,
5355-
TypeExpansionContext context,
5356-
bool allowLoweredTypes) {
5357-
if (!context.shouldLookThroughOpaqueTypeArchetypes() ||
5358-
!ty->hasOpaqueArchetype())
5359-
return ty;
5360-
5361-
ReplaceOpaqueTypesWithUnderlyingTypes replacer(
5362-
context.getContext(), context.getResilienceExpansion(),
5363-
context.isWholeModuleContext());
5364-
SubstOptions flags = (SubstFlags::SubstituteOpaqueArchetypes |
5365-
SubstFlags::PreservePackExpansionLevel);
5366-
if (allowLoweredTypes)
5367-
flags |= SubstFlags::AllowLoweredTypes;
5368-
return ty.subst(replacer, replacer, flags)->getCanonicalType();
5369-
}
5370-
53715354
AnyFunctionType *AnyFunctionType::getWithoutDifferentiability() const {
53725355
SmallVector<Param, 8> newParams;
53735356
for (auto &param : getParams()) {

lib/AST/TypeSubstitution.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,23 @@ operator()(SubstitutableType *maybeOpaqueType) const {
11641164
return substTy;
11651165
}
11661166

1167+
CanType swift::substOpaqueTypesWithUnderlyingTypes(CanType ty,
1168+
TypeExpansionContext context,
1169+
bool allowLoweredTypes) {
1170+
if (!context.shouldLookThroughOpaqueTypeArchetypes() ||
1171+
!ty->hasOpaqueArchetype())
1172+
return ty;
1173+
1174+
ReplaceOpaqueTypesWithUnderlyingTypes replacer(
1175+
context.getContext(), context.getResilienceExpansion(),
1176+
context.isWholeModuleContext());
1177+
SubstOptions flags = (SubstFlags::SubstituteOpaqueArchetypes |
1178+
SubstFlags::PreservePackExpansionLevel);
1179+
if (allowLoweredTypes)
1180+
flags |= SubstFlags::AllowLoweredTypes;
1181+
return ty.subst(replacer, replacer, flags)->getCanonicalType();
1182+
}
1183+
11671184
static ProtocolConformanceRef substOpaqueTypesWithUnderlyingTypesRec(
11681185
ProtocolConformanceRef ref, Type origType, const DeclContext *inContext,
11691186
ResilienceExpansion contextExpansion, bool isWholeModuleContext,

0 commit comments

Comments
 (0)