Skip to content

Commit 68af1b7

Browse files
committed
[NFC] AST: Add a proxy for getRoot to CanOpenedArchetypeType
1 parent 21500ab commit 68af1b7

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

include/swift/AST/Types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5878,6 +5878,9 @@ class OpenedArchetypeType final : public ArchetypeType,
58785878
LayoutConstraint layout);
58795879
};
58805880
BEGIN_CAN_TYPE_WRAPPER(OpenedArchetypeType, ArchetypeType)
5881+
CanOpenedArchetypeType getRoot() const {
5882+
return CanOpenedArchetypeType(getPointer()->getRoot());
5883+
}
58815884
END_CAN_TYPE_WRAPPER(OpenedArchetypeType, ArchetypeType)
58825885

58835886
/// An archetype that represents an opaque element of a type sequence in context.

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,7 @@ CanSILFunctionType swift::buildSILFunctionThunkType(
25512551
auto archetypeVisitor = [&](CanType t) {
25522552
if (auto archetypeTy = dyn_cast<ArchetypeType>(t)) {
25532553
if (auto opened = dyn_cast<OpenedArchetypeType>(archetypeTy)) {
2554-
const auto root = cast<OpenedArchetypeType>(CanType(opened->getRoot()));
2554+
const auto root = opened.getRoot();
25552555
assert((openedExistential == CanArchetypeType() ||
25562556
openedExistential == root) &&
25572557
"one too many open existentials");

lib/SIL/IR/SILInstructions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void collectDependentTypeInfo(
5656
return;
5757
Ty.visit([&](CanType t) {
5858
if (const auto opened = dyn_cast<OpenedArchetypeType>(t)) {
59-
const auto root = cast<OpenedArchetypeType>(CanType(opened->getRoot()));
59+
const auto root = opened.getRoot();
6060

6161
// Add this root opened archetype if it was not seen yet.
6262
// We don't use a set here, because the number of open archetypes

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,10 +1469,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
14691469
"Operand is of an ArchetypeType that does not exist in the "
14701470
"Caller's generic param list.");
14711471
if (auto OpenedA = getOpenedArchetypeOf(A)) {
1472-
const auto root =
1473-
cast<OpenedArchetypeType>(CanType(OpenedA->getRoot()));
14741472
auto *openingInst =
1475-
F->getModule().getRootOpenedArchetypeDefInst(root, F);
1473+
F->getModule().getRootOpenedArchetypeDefInst(OpenedA.getRoot(), F);
14761474
require(I == nullptr || openingInst == I ||
14771475
properlyDominates(openingInst, I),
14781476
"Use of an opened archetype should be dominated by a "
@@ -1605,7 +1603,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
16051603
require(isArchetypeValidInFunction(A, AI->getFunction()),
16061604
"Archetype to be substituted must be valid in function.");
16071605

1608-
const auto root = cast<OpenedArchetypeType>(CanType(A->getRoot()));
1606+
const auto root = A.getRoot();
16091607

16101608
// Collect all root opened archetypes used in the substitutions list.
16111609
FoundRootOpenedArchetypes.insert(root);
@@ -4074,10 +4072,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
40744072
Ty.visit([&](CanType t) {
40754073
SILValue Def;
40764074
if (const auto archetypeTy = dyn_cast<OpenedArchetypeType>(t)) {
4077-
const auto root =
4078-
cast<OpenedArchetypeType>(CanType(archetypeTy->getRoot()));
4079-
Def = I->getModule().getRootOpenedArchetypeDefInst(root,
4080-
I->getFunction());
4075+
Def = I->getModule().getRootOpenedArchetypeDefInst(
4076+
archetypeTy.getRoot(), I->getFunction());
40814077
require(Def, "Root opened archetype should be registered in SILModule");
40824078
} else if (t->hasDynamicSelfType()) {
40834079
require(I->getFunction()->hasSelfParam() ||

0 commit comments

Comments
 (0)