[Sema] Insert ErrorType same-type constraints for placeholder signatures

This helps avoid producing more downstream errors. This changes
`GenericSignature::forInvalid` to produce the same signature as e.g
`<T where T == Undefined>`. This subsumes the need to introduce
conformance requirements for invertible protocols.
This commit is contained in:
Hamish Knight
2025-10-08 21:16:02 +01:00
parent 71841bdbd5
commit e7c7239587
7 changed files with 10 additions and 23 deletions

View File

@@ -282,15 +282,11 @@ protocol P2 {
}
// CHECK-LABEL: same_types.(file).structuralSameTypeRecursive1@
// CHECK-NEXT: Generic signature: <T, U>
// CHECK-NEXT: Generic signature: <T, U where T == <<error type>>, U == <<error type>>>
// expected-error@+2 {{cannot build rewrite system for generic signature; concrete type nesting limit exceeded}}
// expected-note@+1 {{τ_0_0.[P2:Assoc1].[concrete: ((((((((((((((((((((((((((((((((τ_0_0.[P2:Assoc1], τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1), τ_0_1)] => τ_0_0.[P2:Assoc1]}}
func structuralSameTypeRecursive1<T: P2, U>(_: T, _: U)
where T.Assoc1 == Tuple2<T.Assoc1, U>
// expected-error@-1 {{'Assoc1' is not a member type of type 'T'}}
// expected-error@-2 {{'Assoc1' is not a member type of type 'T'}}
{ }
func structuralSameTypeRecursive1<T: P2, U>(_: T, _: U) where T.Assoc1 == Tuple2<T.Assoc1, U> {}
protocol P3 {
}