Skip to content

Commit ef99de0

Browse files
committed
AST: Remove useDC parameter from typeEraseOpenedArchetypesWithRoot()
1 parent 5bb82f7 commit ef99de0

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

include/swift/AST/Types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,7 @@ class alignas(1 << TypeAlignInBits) TypeBase
759759

760760
/// Replace opened archetypes with the given root with their most
761761
/// specific non-dependent upper bounds throughout this type.
762-
Type typeEraseOpenedArchetypesWithRoot(const OpenedArchetypeType *root,
763-
const DeclContext *useDC) const;
762+
Type typeEraseOpenedArchetypesWithRoot(const OpenedArchetypeType *root) const;
764763

765764
/// Given a declaration context, returns a function type with the 'self'
766765
/// type curried as the input if the declaration context describes a type.

lib/AST/Type.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,15 @@ void TypeBase::getRootOpenedExistentials(
607607
}
608608

609609
Type TypeBase::typeEraseOpenedArchetypesWithRoot(
610-
const OpenedArchetypeType *root, const DeclContext *useDC) const {
610+
const OpenedArchetypeType *root) const {
611611
assert(root->isRoot() && "Expected a root archetype");
612612

613613
Type type = Type(const_cast<TypeBase *>(this));
614614
if (!hasOpenedExistential())
615615
return type;
616616

617-
const auto sig = root->getASTContext().getOpenedExistentialSignature(
618-
root->getExistentialType(), useDC->getGenericSignatureOfContext());
617+
auto *env = root->getGenericEnvironment();
618+
auto sig = env->getGenericSignature();
619619

620620
unsigned metatypeDepth = 0;
621621

@@ -665,9 +665,8 @@ Type TypeBase::typeEraseOpenedArchetypesWithRoot(
665665
return llvm::None;
666666
}
667667

668-
if (!root->isEqual(archetype->getRoot())) {
668+
if (archetype->getGenericEnvironment() != env)
669669
return Type(ty);
670-
}
671670

672671
Type erasedTy;
673672
if (root->isEqual(archetype)) {

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ namespace {
881881
resultTy = cs.getType(result);
882882
if (resultTy->hasOpenedExistentialWithRoot(record.Archetype)) {
883883
Type erasedTy = resultTy->typeEraseOpenedArchetypesWithRoot(
884-
record.Archetype, dc);
884+
record.Archetype);
885885
auto range = result->getSourceRange();
886886
result = coerceToType(result, erasedTy, locator);
887887
// FIXME: Implement missing tuple-to-tuple conversion
@@ -1591,7 +1591,7 @@ namespace {
15911591
// Erase opened existentials from the type of the thunk; we're
15921592
// going to open the existential inside the thunk's body.
15931593
containerTy = containerTy->typeEraseOpenedArchetypesWithRoot(
1594-
knownOpened->second, dc);
1594+
knownOpened->second);
15951595
selfTy = containerTy;
15961596
}
15971597
}
@@ -1674,7 +1674,7 @@ namespace {
16741674
// existential.
16751675
if (openedExistential) {
16761676
refType = refType->typeEraseOpenedArchetypesWithRoot(
1677-
baseTy->castTo<OpenedArchetypeType>(), dc);
1677+
baseTy->castTo<OpenedArchetypeType>());
16781678
}
16791679

16801680
return refType;
@@ -1885,7 +1885,7 @@ namespace {
18851885
if (knownOpened != solution.OpenedExistentialTypes.end()) {
18861886
curryThunkTy =
18871887
curryThunkTy
1888-
->typeEraseOpenedArchetypesWithRoot(knownOpened->second, dc)
1888+
->typeEraseOpenedArchetypesWithRoot(knownOpened->second)
18891889
->castTo<FunctionType>();
18901890
}
18911891
}

0 commit comments

Comments
 (0)