Use match_first to make the impl_recurse_with_simpler_type_in_generic_param_bidirectional_no_cycle.carbon test pass again (#7712)

This commit is contained in:
Dana Jansens
2026-09-02 21:56:12 +00:00
committed by GitHub
parent 95897201ee
commit b6ba4ecdbb
+4 -17
View File
@@ -246,7 +246,7 @@ fn F() {
({} as Wraps(C)) as (Wraps(C) as ComparableTo(Wraps(D)));
}
// --- fail_todo_impl_recurse_with_simpler_type_in_generic_param_bidirectional_no_cycle.carbon
// --- impl_recurse_with_simpler_type_in_generic_param_bidirectional_no_cycle.carbon
library "[[@TEST_NAME]]";
// Implement this for a type in one direction.
@@ -262,30 +262,17 @@ class D {}
// - D is ComparableWith(C).
impl C as ComparableTo(D) {}
// TODO: These three `impl`s need to be placed in a match_first as they
// overlap.
match_first {
// T is always ComparableWith(T).
impl forall [T: type] T as ComparableWith(T) {}
// If U is ComparableTo(T), U is ComparableWith(T).
// CHECK:STDERR: fail_todo_impl_recurse_with_simpler_type_in_generic_param_bidirectional_no_cycle.carbon:[[@LINE+7]]:1: error: found non-final `impl` with the same type structure as another non-final `impl` [ImplNonFinalSameTypeStructure]
// CHECK:STDERR: impl forall [T: type, U: ComparableTo(T)] U as ComparableWith(T) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_todo_impl_recurse_with_simpler_type_in_generic_param_bidirectional_no_cycle.carbon:[[@LINE-5]]:1: note: other `impl` here [ImplNonFinalSameTypeStructureNote]
// CHECK:STDERR: impl forall [T: type] T as ComparableWith(T) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
impl forall [T: type, U: ComparableTo(T)] U as ComparableWith(T) {}
// If U is ComparableTo(T), T is ComparableWith(U).
// CHECK:STDERR: fail_todo_impl_recurse_with_simpler_type_in_generic_param_bidirectional_no_cycle.carbon:[[@LINE+7]]:1: error: found non-final `impl` with the same type structure as another non-final `impl` [ImplNonFinalSameTypeStructure]
// CHECK:STDERR: impl forall [T: type, U: ComparableTo(T)] T as ComparableWith(U) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_todo_impl_recurse_with_simpler_type_in_generic_param_bidirectional_no_cycle.carbon:[[@LINE-14]]:1: note: other `impl` here [ImplNonFinalSameTypeStructureNote]
// CHECK:STDERR: impl forall [T: type] T as ComparableWith(T) {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
impl forall [T: type, U: ComparableTo(T)] T as ComparableWith(U) {}
}
fn Compare[T: type, U: ComparableWith(T)](unused t: T, unused u: U) {}
fn F() {