Skip to content

Commit a5a50a3

Browse files
committed
[AST] NFC: Rename underlying type accessors of OpaqueTypeDecl
Adds a `Unique` component to the accessor names to draw the distinction between unique and conditionally available substitutions.
1 parent 67311e5 commit a5a50a3

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

include/swift/AST/Decl.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,7 +2840,7 @@ class OpaqueTypeDecl final :
28402840
/// expressed as a SubstitutionMap for the opaque interface generic signature.
28412841
/// This maps types in the interface generic signature to the outer generic
28422842
/// signature of the original declaration.
2843-
Optional<SubstitutionMap> UnderlyingTypeSubstitutions;
2843+
Optional<SubstitutionMap> UniqueUnderlyingType;
28442844

28452845
/// A set of substitutions which are used based on the availability
28462846
/// checks performed at runtime. This set of only populated if there
@@ -2922,16 +2922,16 @@ class OpaqueTypeDecl final :
29222922
}
29232923

29242924
/// The substitutions that map the generic parameters of the opaque type to
2925-
/// their underlying types, when that information is known.
2926-
Optional<SubstitutionMap> getUnderlyingTypeSubstitutions() const {
2927-
return UnderlyingTypeSubstitutions;
2925+
/// the unique underlying types, when that information is known.
2926+
Optional<SubstitutionMap> getUniqueUnderlyingTypeSubstitutions() const {
2927+
return UniqueUnderlyingType;
29282928
}
29292929

2930-
void setUnderlyingTypeSubstitutions(SubstitutionMap subs) {
2931-
assert(!UnderlyingTypeSubstitutions.hasValue() && "resetting underlying type?!");
2932-
UnderlyingTypeSubstitutions = subs;
2930+
void setUniqueUnderlyingTypeSubstitutions(SubstitutionMap subs) {
2931+
assert(!UniqueUnderlyingType.hasValue() && "resetting underlying type?!");
2932+
UniqueUnderlyingType = subs;
29332933
}
2934-
t
2934+
29352935
void setConditionallyAvailableSubstitutions(
29362936
ArrayRef<ConditionallyAvailableSubstitutions *> substitutions) {
29372937
assert(!ConditionallyAvailableTypes &&

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ namespace {
572572
<< OTD->getDeclaredInterfaceType().getString();
573573
OS << " in "
574574
<< OTD->getOpaqueInterfaceGenericSignature()->getAsString();
575-
if (auto underlyingSubs = OTD->getUnderlyingTypeSubstitutions()) {
575+
if (auto underlyingSubs = OTD->getUniqueUnderlyingTypeSubstitutions()) {
576576
OS << " underlying:\n";
577577
SmallPtrSet<const ProtocolConformance *, 4> Dumped;
578578
dumpSubstitutionMapRec(*underlyingSubs, OS,

lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,7 +3638,7 @@ operator()(SubstitutableType *maybeOpaqueType) const {
36383638
return maybeOpaqueType;
36393639
}
36403640

3641-
auto subs = opaqueRoot->getDecl()->getUnderlyingTypeSubstitutions();
3641+
auto subs = opaqueRoot->getDecl()->getUniqueUnderlyingTypeSubstitutions();
36423642
// If the body of the opaque decl providing decl has not been type checked we
36433643
// don't have a underlying subsitution.
36443644
if (!subs.hasValue())
@@ -3749,7 +3749,7 @@ operator()(CanType maybeOpaqueType, Type replacementType,
37493749
return abstractRef;
37503750
}
37513751

3752-
auto subs = opaqueRoot->getDecl()->getUnderlyingTypeSubstitutions();
3752+
auto subs = opaqueRoot->getDecl()->getUniqueUnderlyingTypeSubstitutions();
37533753
// If the body of the opaque decl providing decl has not been type checked we
37543754
// don't have a underlying subsitution.
37553755
if (!subs.hasValue())

lib/IRGen/GenMeta.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ namespace {
20402040
void addUnderlyingTypeAndConformances() {
20412041
auto sig = O->getOpaqueInterfaceGenericSignature();
20422042
auto contextSig = O->getGenericSignature().getCanonicalSignature();
2043-
auto subs = *O->getUnderlyingTypeSubstitutions();
2043+
auto subs = *O->getUniqueUnderlyingTypeSubstitutions();
20442044

20452045
// Add the underlying types for each generic parameter.
20462046
for (auto genericParam : O->getOpaqueGenericParams()) {

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8442,7 +8442,7 @@ static Optional<SolutionApplicationTarget> applySolutionToInitialization(
84428442
return expr;
84438443
});
84448444

8445-
opaque->setUnderlyingTypeSubstitutions(substitutions);
8445+
opaque->setUniqueUnderlyingTypeSubstitutions(substitutions);
84468446
}
84478447
}
84488448

lib/Sema/MiscDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,7 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
27132713

27142714
// If we have one successful candidate, then save it as the underlying
27152715
// substitutions of the opaque decl.
2716-
OpaqueDecl->setUnderlyingTypeSubstitutions(
2716+
OpaqueDecl->setUniqueUnderlyingTypeSubstitutions(
27172717
underlyingSubs.mapReplacementTypesOutOfContext());
27182718
}
27192719

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,7 @@ class DeclDeserializer {
35713571
auto subMapOrError = MF.getSubstitutionMapChecked(underlyingTypeSubsID);
35723572
if (!subMapOrError)
35733573
return subMapOrError.takeError();
3574-
opaqueDecl->setUnderlyingTypeSubstitutions(subMapOrError.get());
3574+
opaqueDecl->setUniqueUnderlyingTypeSubstitutions(subMapOrError.get());
35753575
}
35763576
return opaqueDecl;
35773577
}

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3898,7 +3898,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
38983898
auto genericSigID = S.addGenericSignatureRef(opaqueDecl->getGenericSignature());
38993899

39003900
SubstitutionMapID underlyingSubsID = 0;
3901-
if (auto underlying = opaqueDecl->getUnderlyingTypeSubstitutions())
3901+
if (auto underlying = opaqueDecl->getUniqueUnderlyingTypeSubstitutions())
39023902
underlyingSubsID = S.addSubstitutionMapRef(*underlying);
39033903
uint8_t rawAccessLevel =
39043904
getRawStableAccessLevel(opaqueDecl->getFormalAccess());

0 commit comments

Comments
 (0)