Skip to content

Commit b08014a

Browse files
committed
Make OpaqueSubstitutionKind an enum class. No functionality change.
Also fix a comment typo while I'm here.
1 parent c95ef11 commit b08014a

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

include/swift/AST/Types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4876,7 +4876,7 @@ class OpaqueTypeArchetypeType final : public ArchetypeType,
48764876
BEGIN_CAN_TYPE_WRAPPER(OpaqueTypeArchetypeType, ArchetypeType)
48774877
END_CAN_TYPE_WRAPPER(OpaqueTypeArchetypeType, ArchetypeType)
48784878

4879-
enum OpaqueSubstitutionKind {
4879+
enum class OpaqueSubstitutionKind {
48804880
// Don't substitute the opaque type for the underlying type.
48814881
DontSubstitute,
48824882
// Substitute without looking at the type and context.
@@ -4885,7 +4885,7 @@ enum OpaqueSubstitutionKind {
48854885
AlwaysSubstitute,
48864886
// Substitute in the same module into a maximal resilient context.
48874887
// Can be done if the underlying type is accessible from the context we
4888-
// substitute into. Private types cannot be accesses from a different TU.
4888+
// substitute into. Private types cannot be accessed from a different TU.
48894889
SubstituteSameModuleMaximalResilience,
48904890
// Substitute in a different module from the opaque definining decl. Can only
48914891
// be done if the underlying type is public.

lib/AST/Type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,21 +2660,21 @@ bool canSubstituteTypeInto(Type ty, DeclContext *dc,
26602660
return true;
26612661

26622662
switch (kind) {
2663-
case DontSubstitute:
2663+
case OpaqueSubstitutionKind::DontSubstitute:
26642664
return false;
26652665

2666-
case AlwaysSubstitute:
2666+
case OpaqueSubstitutionKind::AlwaysSubstitute:
26672667
return true;
26682668

2669-
case SubstituteSameModuleMaximalResilience:
2669+
case OpaqueSubstitutionKind::SubstituteSameModuleMaximalResilience:
26702670
// In the same file any visibility is okay.
26712671
if (!dc->isModuleContext() &&
26722672
nominal->getDeclContext()->getParentSourceFile() ==
26732673
dc->getParentSourceFile())
26742674
return true;
26752675
return nominal->getEffectiveAccess() > AccessLevel::FilePrivate;
26762676

2677-
case SubstituteNonResilientModule:
2677+
case OpaqueSubstitutionKind::SubstituteNonResilientModule:
26782678
// Can't access types that are not public from a different module.
26792679
return nominal->getEffectiveAccess() > AccessLevel::Internal;
26802680
}

lib/SILOptimizer/Transforms/SpecializeOpaqueArchetypes.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,12 @@ class OpaqueArchetypeSpecializer : public SILFunctionTransform {
508508
if (!dc)
509509
dc = context->getModule().getSwiftModule();
510510
auto opaque = opaqueTy->getDecl();
511-
return ReplaceOpaqueTypesWithUnderlyingTypes::
511+
OpaqueSubstitutionKind subKind =
512+
ReplaceOpaqueTypesWithUnderlyingTypes::
512513
shouldPerformSubstitution(opaque,
513514
context->getModule().getSwiftModule(),
514515
context->getResilienceExpansion());
516+
return subKind != OpaqueSubstitutionKind::DontSubstitute;
515517
}
516518
return false;
517519
});

0 commit comments

Comments
 (0)