Skip to content

Remove an unnecessary assertion. #60040

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
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion lib/AST/ExistentialGeneralization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,14 @@ class Generalizer : public CanTypeVisitor<Generalizer, Type> {
ExistentialTypeGeneralization
ExistentialTypeGeneralization::get(Type rawType) {
assert(rawType->isAnyExistentialType());
assert(!rawType->hasTypeParameter());

// Canonicalize. We need to generalize the canonical shape of the
// type or else generalization parameters won't match up.
//
// TODO: in full generality, do we need to do *contextual*
// canonicalization in order to avoid introducing non-canonical
// parameters? (That is, do we need a contextual generic
// signature if given an interface type?)
CanType type = rawType->getCanonicalType();

Generalizer generalizer(type->getASTContext());
Expand Down
9 changes: 9 additions & 0 deletions test/Interpreter/parameterized_existentials.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@ ParameterizedProtocolsTestSuite.test("casting") {
expectEqual(a.value, b.value)
}

// rdar://96571508
struct ErasingHolder<T> {
let box: any Holder<T>
}
ParameterizedProtocolsTestSuite.test("casting") {
let a = ErasingHolder(box: IntHolder(value: 5))
expectEqual(a.box.value, 5)
}

runAllTests()