Skip to content

Commit f3e7daf

Browse files
committed
[NFC] Remove the now-dead PackExpanded accessors from AbstractionPattern
1 parent 4499e3d commit f3e7daf

File tree

2 files changed

+7
-54
lines changed

2 files changed

+7
-54
lines changed

include/swift/SIL/AbstractionPattern.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,19 +1543,15 @@ class AbstractionPattern {
15431543
AbstractionPattern getObjCMethodAsyncCompletionHandlerType(
15441544
CanType swiftCompletionHandlerType) const;
15451545

1546-
/// Given that this is a pack expansion, invoke the given callback for
1547-
/// each component of the substituted expansion of this pattern. The
1548-
/// pattern will be for a pack expansion type over a contextual type if
1549-
/// the substituted component is still a pack expansion. If there aren't
1550-
/// substitutions available, this will just invoke the callback with the
1551-
/// component.
1552-
void forEachPackExpandedComponent(
1553-
llvm::function_ref<void(AbstractionPattern pattern)> fn) const;
1554-
1546+
/// Given that this is a pack expansion, return the number of components
1547+
/// that it should expand to. This, and the general correctness of
1548+
/// traversing variadically generic tuple and function types under
1549+
/// substitution, relies on substitutions having been set properly
1550+
/// on the abstraction pattern; without that, AbstractionPattern assumes
1551+
/// that every component expands to a single pack expansion component,
1552+
/// which will generally only work in specific situations.
15551553
size_t getNumPackExpandedComponents() const;
15561554

1557-
SmallVector<AbstractionPattern, 4> getPackExpandedComponents() const;
1558-
15591555
/// If this pattern refers to a foreign ObjC method that was imported as
15601556
/// async, return the bridged-back-to-ObjC completion handler type.
15611557
CanType getObjCMethodAsyncCompletionHandlerForeignType(

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -675,15 +675,6 @@ AbstractionPattern AbstractionPattern::getPackExpansionPatternType() const {
675675
llvm_unreachable("bad kind");
676676
}
677677

678-
SmallVector<AbstractionPattern, 4>
679-
AbstractionPattern::getPackExpandedComponents() const {
680-
SmallVector<AbstractionPattern, 4> result;
681-
forEachPackExpandedComponent([&](AbstractionPattern pattern) {
682-
result.push_back(pattern);
683-
});
684-
return result;
685-
}
686-
687678
size_t AbstractionPattern::getNumPackExpandedComponents() const {
688679
assert(isPackExpansion());
689680
assert(getKind() == Kind::Type || getKind() == Kind::Discard);
@@ -699,40 +690,6 @@ size_t AbstractionPattern::getNumPackExpandedComponents() const {
699690
return substShape->getNumElements();
700691
}
701692

702-
void AbstractionPattern::forEachPackExpandedComponent(
703-
llvm::function_ref<void (AbstractionPattern)> fn) const {
704-
assert(isPackExpansion());
705-
706-
switch (getKind()) {
707-
case Kind::Type:
708-
case Kind::Discard: {
709-
// If we don't have generic substitutions, just produce this pattern.
710-
if (!GenericSubs) return fn(*this);
711-
auto origExpansion = cast<PackExpansionType>(getType());
712-
713-
// Substitute the expansion shape.
714-
auto substShape = cast<PackType>(
715-
origExpansion.getCountType().subst(GenericSubs)->getCanonicalType());
716-
717-
// Call the callback with each component of the substituted shape.
718-
for (auto substShapeElt : substShape.getElementTypes()) {
719-
CanType origEltType = origExpansion.getPatternType();
720-
if (auto substShapeEltExpansion =
721-
dyn_cast<PackExpansionType>(substShapeElt)) {
722-
origEltType = CanPackExpansionType::get(origEltType,
723-
substShapeEltExpansion.getCountType());
724-
}
725-
fn(AbstractionPattern(GenericSubs, GenericSig, origEltType));
726-
}
727-
return;
728-
}
729-
730-
default:
731-
llvm_unreachable("not a pack expansion");
732-
}
733-
llvm_unreachable("bad kind");
734-
}
735-
736693
AbstractionPattern AbstractionPattern::removingMoveOnlyWrapper() const {
737694
switch (getKind()) {
738695
case Kind::Invalid:

0 commit comments

Comments
 (0)