Skip to content

Commit cf784f9

Browse files
committed
AST: Remove SubstFlags::AllowLoweredTypes
1 parent 76ec490 commit cf784f9

File tree

12 files changed

+16
-48
lines changed

12 files changed

+16
-48
lines changed

include/swift/AST/Type.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,22 @@ class MakeAbstractConformanceForGenericType {
117117

118118
/// Flags that can be passed when substituting into a type.
119119
enum class SubstFlags {
120-
/// Allow substitutions to recurse into SILFunctionTypes. Normally,
121-
/// SILType::subst() should be used for lowered types, however in special
122-
/// cases where the substitution is just changing between contextual and
123-
/// interface type representations, using Type::subst() is allowed.
124-
AllowLoweredTypes = 0x01,
125120
/// Map member types to their desugared witness type.
126-
DesugarMemberTypes = 0x02,
121+
DesugarMemberTypes = 0x01,
127122
/// Allow primary archetypes to themselves be the subject of substitution.
128123
/// Otherwise, we map them out of context first.
129-
SubstitutePrimaryArchetypes = 0x04,
124+
SubstitutePrimaryArchetypes = 0x02,
130125
/// Allow opaque archetypes to themselves be the subject of substitution,
131126
/// used when erasing them to their underlying types. Otherwise, we
132127
/// recursively substitute their substitutions, instead, preserving the
133128
/// opaque archetype.
134-
SubstituteOpaqueArchetypes = 0x08,
129+
SubstituteOpaqueArchetypes = 0x04,
135130
/// Allow local archetypes to themselves be the subject of substitution.
136-
SubstituteLocalArchetypes = 0x10,
131+
SubstituteLocalArchetypes = 0x08,
137132
/// Don't increase pack expansion level for free pack references.
138133
/// Do not introduce new usages of this flag.
139134
/// FIXME: Remove this.
140-
PreservePackExpansionLevel = 0x20,
135+
PreservePackExpansionLevel = 0x10,
141136
};
142137

143138
/// Options for performing substitutions into a type.

include/swift/AST/Types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4803,8 +4803,7 @@ class SILFunctionConventions;
48034803

48044804

48054805
CanType substOpaqueTypesWithUnderlyingTypes(CanType type,
4806-
TypeExpansionContext context,
4807-
bool allowLoweredTypes = false);
4806+
TypeExpansionContext context);
48084807
ProtocolConformanceRef
48094808
substOpaqueTypesWithUnderlyingTypes(ProtocolConformanceRef ref, Type origType,
48104809
TypeExpansionContext context);

include/swift/SIL/SILCloner.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,7 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
548548
return ty;
549549

550550
// Remap types containing opaque result types in the current context.
551-
return substOpaqueTypesWithUnderlyingTypes(ty, context,
552-
/*allowLoweredTypes=*/false);
551+
return substOpaqueTypesWithUnderlyingTypes(ty, context);
553552
}
554553

555554
return ty;

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,7 @@ static Type getTypeForDWARFMangling(Type t) {
699699
}
700700
return t->getCanonicalType();
701701
},
702-
MakeAbstractConformanceForGenericType(),
703-
SubstFlags::AllowLoweredTypes);
702+
MakeAbstractConformanceForGenericType());
704703
}
705704

706705
std::string ASTMangler::mangleTypeForDebugger(Type Ty, GenericSignature sig) {

lib/AST/GenericEnvironment.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ Type TypeBase::mapTypeOutOfContext() {
377377
assert(!hasTypeParameter() && "already have an interface type");
378378
return Type(this).subst(MapTypeOutOfContext(),
379379
MakeAbstractConformanceForGenericType(),
380-
SubstFlags::AllowLoweredTypes |
381380
SubstFlags::PreservePackExpansionLevel |
382381
SubstFlags::SubstitutePrimaryArchetypes);
383382
}
@@ -580,7 +579,6 @@ Type GenericEnvironment::mapTypeIntoContext(
580579

581580
Type result = type.subst(QueryInterfaceTypeSubstitutions(this),
582581
lookupConformance,
583-
SubstFlags::AllowLoweredTypes |
584582
SubstFlags::PreservePackExpansionLevel);
585583
assert((!result->hasTypeParameter() || result->hasError() ||
586584
getKind() == Kind::Opaque) &&
@@ -717,7 +715,6 @@ GenericEnvironment::mapElementTypeIntoPackContext(Type type) const {
717715
return archetype->getInterfaceType();
718716
},
719717
MakeAbstractConformanceForGenericType(),
720-
SubstFlags::AllowLoweredTypes |
721718
SubstFlags::PreservePackExpansionLevel |
722719
SubstFlags::SubstitutePrimaryArchetypes |
723720
SubstFlags::SubstituteLocalArchetypes);

lib/AST/RequirementMachine/RequirementMachineRequests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,6 @@ AbstractGenericSignatureRequest::evaluate(
629629
return Type(type);
630630
},
631631
MakeAbstractConformanceForGenericType(),
632-
SubstFlags::AllowLoweredTypes |
633632
SubstFlags::PreservePackExpansionLevel);
634633
resugaredRequirements.push_back(resugaredReq);
635634
}

lib/AST/TypeSubstitution.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,6 @@ class TypeSubstituter : public TypeTransform<TypeSubstituter> {
523523

524524
std::optional<Type>
525525
TypeSubstituter::transform(TypeBase *type, TypePosition position) {
526-
// FIXME: Add SIL versions of mapTypeIntoContext() and
527-
// mapTypeOutOfContext() and use them appropriately
528-
assert((IFS.getOptions().contains(SubstFlags::AllowLoweredTypes) ||
529-
!isa<SILFunctionType>(type)) &&
530-
"should not be doing AST type-substitution on a lowered SIL type;"
531-
"use SILType::subst");
532-
533526
return std::nullopt;
534527
}
535528

@@ -1308,8 +1301,7 @@ operator()(SubstitutableType *maybeOpaqueType) const {
13081301
}
13091302

13101303
CanType swift::substOpaqueTypesWithUnderlyingTypes(CanType ty,
1311-
TypeExpansionContext context,
1312-
bool allowLoweredTypes) {
1304+
TypeExpansionContext context) {
13131305
if (!context.shouldLookThroughOpaqueTypeArchetypes() ||
13141306
!ty->hasOpaqueArchetype())
13151307
return ty;
@@ -1319,8 +1311,6 @@ CanType swift::substOpaqueTypesWithUnderlyingTypes(CanType ty,
13191311
context.isWholeModuleContext());
13201312
SubstOptions flags = (SubstFlags::SubstituteOpaqueArchetypes |
13211313
SubstFlags::PreservePackExpansionLevel);
1322-
if (allowLoweredTypes)
1323-
flags |= SubstFlags::AllowLoweredTypes;
13241314
return ty.subst(replacer, replacer, flags)->getCanonicalType();
13251315
}
13261316

lib/IRGen/GenType.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,6 @@ CanType TypeConverter::getExemplarType(CanType contextTy) {
20152015
return type;
20162016
},
20172017
MakeAbstractConformanceForGenericType(),
2018-
SubstFlags::AllowLoweredTypes |
20192018
SubstFlags::PreservePackExpansionLevel |
20202019
SubstFlags::SubstitutePrimaryArchetypes);
20212020
return CanType(exemplified);

lib/IRGen/MetadataRequest.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ CanType IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type) {
531531
// assume are constant.
532532
if (type->hasOpaqueArchetype()) {
533533
auto context = getMaximalTypeExpansionContext();
534-
return swift::substOpaqueTypesWithUnderlyingTypes(type, context,
535-
/*allowLoweredTypes=*/false);
534+
return swift::substOpaqueTypesWithUnderlyingTypes(type, context);
536535
}
537536

538537
return type;
@@ -545,8 +544,7 @@ SILType IRGenModule::substOpaqueTypesWithUnderlyingTypes(
545544
if (type.getASTType()->hasOpaqueArchetype()) {
546545
auto context = getMaximalTypeExpansionContext();
547546
return SILType::getPrimitiveType(
548-
swift::substOpaqueTypesWithUnderlyingTypes(type.getASTType(), context,
549-
/*allowLoweredTypes=*/true),
547+
swift::substOpaqueTypesWithUnderlyingTypes(type.getASTType(), context),
550548
type.getCategory());
551549
}
552550

@@ -561,8 +559,7 @@ IRGenModule::substOpaqueTypesWithUnderlyingTypes(CanType type,
561559
if (type->hasOpaqueArchetype()) {
562560
auto context = getMaximalTypeExpansionContext();
563561
return std::make_pair(
564-
swift::substOpaqueTypesWithUnderlyingTypes(type, context,
565-
/*allowLoweredTypes=*/false),
562+
swift::substOpaqueTypesWithUnderlyingTypes(type, context),
566563
swift::substOpaqueTypesWithUnderlyingTypes(conformance, type, context));
567564
}
568565

lib/SIL/IR/SILFunction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ Type SILFunction::mapTypeIntoContext(Type type) const {
504504
// environment.
505505
return type.subst(MapIntoLocalArchetypeContext(GenericEnv, CapturedEnvs),
506506
LookUpConformanceInModule(),
507-
SubstFlags::AllowLoweredTypes |
508507
SubstFlags::PreservePackExpansionLevel);
509508
}
510509

0 commit comments

Comments
 (0)