Skip to content

Remove unused DeclContext #36679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/Sema/TypeCheckSwitchStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace {
case SpaceKind::UnknownCase:
return isAllowedButNotRequired() ? 0 : 1;
case SpaceKind::Type: {
if (!canDecompose(getType(), DC)) {
if (!canDecompose(getType())) {
return 1;
}
cache.insert(getType().getPointer());
Expand Down Expand Up @@ -316,14 +316,14 @@ namespace {
}

// (_ : Ty1) <= (_ : Ty2) iff D(Ty1) == D(Ty2)
if (canDecompose(this->getType(), DC)) {
if (canDecompose(this->getType())) {
Space or1Space = decompose(DC, this->getType());
if (or1Space.isSubspace(other, DC)) {
return true;
}
}

if (canDecompose(other.getType(), DC)) {
if (canDecompose(other.getType())) {
Space or2Space = decompose(DC, other.getType());
return this->isSubspace(or2Space, DC);
}
Expand All @@ -339,15 +339,15 @@ namespace {
}

// (_ : Ty1) <= (S1 | ... | Sn) iff D(Ty1) <= (S1 | ... | Sn)
if (!canDecompose(this->getType(), DC)) {
if (!canDecompose(this->getType())) {
return false;
}
Space or1Space = decompose(DC, this->getType());
return or1Space.isSubspace(other, DC);
}
PAIRCASE (SpaceKind::Type, SpaceKind::Constructor): {
// (_ : Ty1) <= H(p1 | ... | pn) iff D(Ty1) <= H(p1 | ... | pn)
if (canDecompose(this->getType(), DC)) {
if (canDecompose(this->getType())) {
Space or1Space = decompose(DC, this->getType());
return or1Space.isSubspace(other, DC);
}
Expand Down Expand Up @@ -465,7 +465,7 @@ namespace {
return *this;
}
PAIRCASE (SpaceKind::Type, SpaceKind::Constructor): {
if (canDecompose(this->getType(), DC)) {
if (canDecompose(this->getType())) {
auto decomposition = decompose(DC, this->getType());
return decomposition.minus(other, DC, minusCount);
} else {
Expand Down Expand Up @@ -627,7 +627,7 @@ namespace {
return (getKind() == SpaceKind::BooleanConstant) ? Space() : *this;
}

if (canDecompose(other.getType(), DC)) {
if (canDecompose(other.getType())) {
auto decomposition = decompose(DC, other.getType());
return this->minus(decomposition, DC, minusCount);
}
Expand All @@ -639,7 +639,7 @@ namespace {
return *this;

PAIRCASE (SpaceKind::Type, SpaceKind::BooleanConstant): {
if (canDecompose(this->getType(), DC)) {
if (canDecompose(this->getType())) {
auto orSpace = decompose(DC, this->getType());
return orSpace.minus(other, DC, minusCount);
} else {
Expand Down Expand Up @@ -781,7 +781,7 @@ namespace {
// Decompose a type into its component spaces.
static void decompose(const DeclContext *DC, Type tp,
SmallVectorImpl<Space> &arr) {
assert(canDecompose(tp, DC) && "Non-decomposable type?");
assert(canDecompose(tp) && "Non-decomposable type?");

if (tp->isBool()) {
arr.push_back(Space::forBool(true));
Expand Down Expand Up @@ -844,7 +844,7 @@ namespace {
return Space::forDisjunct(spaces);
}

static bool canDecompose(Type tp, const DeclContext *DC) {
static bool canDecompose(Type tp) {
return tp->is<TupleType>() || tp->isBool() ||
tp->getEnumOrBoundGenericEnum();
}
Expand Down Expand Up @@ -1032,7 +1032,7 @@ namespace {
// decompose the type space and offer them as fixits, or simply offer
// to insert a `default` clause.
if (uncovered.getKind() == SpaceKind::Type) {
if (Space::canDecompose(uncovered.getType(), DC)) {
if (Space::canDecompose(uncovered.getType())) {
SmallVector<Space, 4> spaces;
Space::decompose(DC, uncovered.getType(), spaces);
diagnoseMissingCases(RequiresDefault::No, Space::forDisjunct(spaces),
Expand Down