Skip to content

Commit 4edfd79

Browse files
committed
[NFC] Add a convenience function to IFS
1 parent 06b5c97 commit 4edfd79

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

include/swift/AST/InFlightSubstitution.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ class InFlightSubstitution {
5959
return Options;
6060
}
6161

62+
bool shouldSubstituteOpaqueArchetypes() const {
63+
return Options.contains(SubstFlags::SubstituteOpaqueArchetypes);
64+
}
65+
6266
/// Is the given type invariant to substitution?
6367
bool isInvariant(Type type) const;
6468
};

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ ProtocolConformanceRef::subst(Type origType, InFlightSubstitution &IFS) const {
8686
// If the type is an opaque archetype, the conformance will remain abstract,
8787
// unless we're specifically substituting opaque types.
8888
if (auto origArchetype = origType->getAs<ArchetypeType>()) {
89-
if (!IFS.getOptions().contains(SubstFlags::SubstituteOpaqueArchetypes)
89+
if (!IFS.shouldSubstituteOpaqueArchetypes()
9090
&& isa<OpaqueTypeArchetypeType>(origArchetype)) {
9191
return *this;
9292
}

lib/AST/SubstitutionMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ SubstitutionMap SubstitutionMap::subst(InFlightSubstitution &IFS) const {
485485
// Fast path for concrete case -- we don't need to compute substType
486486
// at all.
487487
if (conformance.isConcrete() &&
488-
!IFS.getOptions().contains(SubstFlags::SubstituteOpaqueArchetypes)) {
488+
!IFS.shouldSubstituteOpaqueArchetypes()) {
489489
newConformances.push_back(
490490
ProtocolConformanceRef(conformance.getConcrete()->subst(IFS)));
491491
} else {

lib/AST/Type.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4655,7 +4655,7 @@ static Type substGenericFunctionType(GenericFunctionType *genericFnType,
46554655
bool InFlightSubstitution::isInvariant(Type derivedType) const {
46564656
return !derivedType->hasArchetype()
46574657
&& !derivedType->hasTypeParameter()
4658-
&& (!Options.contains(SubstFlags::SubstituteOpaqueArchetypes)
4658+
&& (!shouldSubstituteOpaqueArchetypes()
46594659
|| !derivedType->hasOpaqueArchetype());
46604660
}
46614661

@@ -4742,13 +4742,13 @@ static Type substType(Type derivedType, InFlightSubstitution &IFS) {
47424742

47434743
// Opaque types can't normally be directly substituted unless we
47444744
// specifically were asked to substitute them.
4745-
if (!IFS.getOptions().contains(SubstFlags::SubstituteOpaqueArchetypes)
4745+
if (!IFS.shouldSubstituteOpaqueArchetypes()
47464746
&& isa<OpaqueTypeArchetypeType>(substOrig))
47474747
return None;
47484748

47494749
// If we have a substitution for this type, use it.
47504750
if (auto known = IFS.substType(substOrig)) {
4751-
if (IFS.getOptions().contains(SubstFlags::SubstituteOpaqueArchetypes) &&
4751+
if (IFS.shouldSubstituteOpaqueArchetypes() &&
47524752
isa<OpaqueTypeArchetypeType>(substOrig) &&
47534753
known->getCanonicalType() == substOrig->getCanonicalType())
47544754
return None; // Recursively process the substitutions of the opaque type

0 commit comments

Comments
 (0)