Skip to content

Commit 7a41749

Browse files
authored
Remove an unnecessary assertion. (#60046)
I did check that the code doesn't actually rely on not seeing a type parameter. rdar://96571508
1 parent 30d0b1c commit 7a41749

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
@@ -267,10 +267,14 @@ class Generalizer : public CanTypeVisitor<Generalizer, Type> {
267267
ExistentialTypeGeneralization
268268
ExistentialTypeGeneralization::get(Type rawType) {
269269
assert(rawType->isAnyExistentialType());
270-
assert(!rawType->hasTypeParameter());
271270

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

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

test/Interpreter/parameterized_existentials.swift

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

47+
// rdar://96571508
48+
struct ErasingHolder<T> {
49+
let box: any Holder<T>
50+
}
51+
ParameterizedProtocolsTestSuite.test("casting") {
52+
let a = ErasingHolder(box: IntHolder(value: 5))
53+
expectEqual(a.box.value, 5)
54+
}
55+
4756
runAllTests()
4857

0 commit comments

Comments
 (0)