Skip to content

Commit 43ccd9e

Browse files
authored
Merge pull request #60040 from rjmccall/remove-existential-generalization-assertion
Remove an unnecessary assertion.
2 parents bee4eae + e60095e commit 43ccd9e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/AST/ExistentialGeneralization.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,14 @@ class Generalizer : public CanTypeVisitor<Generalizer, Type> {
268268
ExistentialTypeGeneralization
269269
ExistentialTypeGeneralization::get(Type rawType) {
270270
assert(rawType->isAnyExistentialType());
271-
assert(!rawType->hasTypeParameter());
272271

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

277281
Generalizer generalizer(type->getASTContext());

test/Interpreter/parameterized_existentials.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,14 @@ ParameterizedProtocolsTestSuite.test("casting") {
4949
expectEqual(a.value, b.value)
5050
}
5151

52+
// rdar://96571508
53+
struct ErasingHolder<T> {
54+
let box: any Holder<T>
55+
}
56+
ParameterizedProtocolsTestSuite.test("casting") {
57+
let a = ErasingHolder(box: IntHolder(value: 5))
58+
expectEqual(a.box.value, 5)
59+
}
60+
5261
runAllTests()
5362

0 commit comments

Comments
 (0)