Skip to content

Commit 38a6726

Browse files
committed
[Constraint System] Fix covariant erasure for constrained existentials
Use of an associated type in the member is not considered invariant if that associated type has been made concrete by the existential type.
1 parent 4b9334e commit 38a6726

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ typeEraseExistentialSelfReferences(
21032103
if (t->is<GenericTypeParamType>()) {
21042104
erasedTy = baseTy;
21052105
} else {
2106-
erasedTy = existentialSig->getNonDependentUpperBounds(t);
2106+
erasedTy = existentialSig->getDependentUpperBounds(t);
21072107
}
21082108

21092109
if (metatypeDepth) {

test/type/parameterized_existential.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,9 @@ func protocolCompositionNotSupported1(_: SomeProto & Sequence<Int>) {}
9191

9292
func protocolCompositionNotSupported2(_: any SomeProto & Sequence<Int>) {}
9393
// expected-error@-1 {{non-protocol, non-class type 'Sequence<Int>' cannot be used within a protocol-constrained type}}
94+
95+
func increment(n : any Sequence<Float>) {
96+
for value in n {
97+
_ = value + 1
98+
}
99+
}

0 commit comments

Comments
 (0)