Skip to content

Commit 8e8f872

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 ac134e4 commit 8e8f872

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
@@ -2113,7 +2113,7 @@ typeEraseExistentialSelfReferences(
21132113
if (t->is<GenericTypeParamType>()) {
21142114
erasedTy = baseTy;
21152115
} else {
2116-
erasedTy = existentialSig->getNonDependentUpperBounds(t);
2116+
erasedTy = existentialSig->getDependentUpperBounds(t);
21172117
}
21182118

21192119
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)