From b8814f6c8086631dd3bbecae54903c5be172a136 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 3 Sep 2026 16:20:13 +0000 Subject: [PATCH] Add named constraints for `Eq` and `Ordered`. (#7714) Also add a default for `EqWith.NotEqual`. Switch advent examples to use these named constraints, and also go through all the other TODOs in the advent examples and fix the ones that are trivially fixable now. --- core/prelude/operators/comparison.carbon | 22 +- examples/advent2024/day10_part2.carbon | 7 +- examples/advent2024/day15_common.carbon | 9 +- examples/advent2024/day4_common.carbon | 28 +- examples/advent2024/day4_part1.carbon | 2 +- examples/advent2024/day4_part2.carbon | 8 +- examples/advent2024/io_utils.carbon | 3 +- examples/advent2024/sort.carbon | 25 +- .../interop/cpp/operators/eq_with.carbon | 96 ++-- .../interop/cpp/operators/ordered_with.carbon | 14 +- .../interop/cpp/operators/spaceship.carbon | 40 +- .../testdata/operators/overloaded/eq.carbon | 509 +----------------- .../operators/overloaded/ordered.carbon | 500 +---------------- 13 files changed, 156 insertions(+), 1107 deletions(-) diff --git a/core/prelude/operators/comparison.carbon b/core/prelude/operators/comparison.carbon index 8e859f53822b..c70bb2b19b3a 100644 --- a/core/prelude/operators/comparison.carbon +++ b/core/prelude/operators/comparison.carbon @@ -5,30 +5,36 @@ package Core library "prelude/operators/comparison"; export import library "prelude/types/bool"; +import library "prelude/copy"; import library "prelude/types/int_literal"; -// TODO: Per the design, for each *With interface there should also be a -// non-With named constraint, such as: -// -// constraint Eq { -// extend require impls EqWith(Self); -// } - // Equality comparison: `a == b` and `a != b`. interface EqWith(Other: type) { fn Equal(self, other: Other) -> bool; - fn NotEqual(self, other: Other) -> bool; + default fn NotEqual(self, other: Other) -> bool { + return not self.Equal(other); + } +} + +constraint Eq { + extend require impls EqWith(Self); } // Relational comparison: `a < b`, `a <= b`, `a > b`, `a >= b`. interface OrderedWith(Other: type) { // TODO: fn Compare + // TODO: Each of the below should be a `default fn` implemented in terms of + // Compare. fn Less(self, other: Other) -> bool; fn LessOrEquivalent(self, other: Other) -> bool; fn Greater(self, other: Other) -> bool; fn GreaterOrEquivalent(self, other: Other) -> bool; } +constraint Ordered { + extend require impls OrderedWith(Self); +} + // Equality comparison for `bool`. // Note that this must be provided in this library as `bool` doesn't have any // associated libraries of its own. diff --git a/examples/advent2024/day10_part2.carbon b/examples/advent2024/day10_part2.carbon index 66bfef9d2b42..6da95c10acd5 100644 --- a/examples/advent2024/day10_part2.carbon +++ b/examples/advent2024/day10_part2.carbon @@ -31,10 +31,9 @@ class PathsToTop { for (x: i32 in Core.Range(43)) { if (terrain.height[x][y] == level) { var paths: i64 = 0; - // TODO: for ((adj_x: i32, adj_y: i32) in adj) { - for (i: i32 in Core.Range(4)) { - let adj_x: i32 = x + adj[i].0; - let adj_y: i32 = y + adj[i].1; + for ((off_x: i32, off_y: i32) in adj) { + let adj_x: i32 = x + off_x; + let adj_y: i32 = y + off_y; if (adj_x >= 0 and adj_x < 43 and adj_y >= 0 and adj_y < 43 and terrain.height[adj_x][adj_y] == level + 1) { diff --git a/examples/advent2024/day15_common.carbon b/examples/advent2024/day15_common.carbon index e59cbee01aab..b96d3ba2523f 100644 --- a/examples/advent2024/day15_common.carbon +++ b/examples/advent2024/day15_common.carbon @@ -18,14 +18,9 @@ class Square { return (self as char).(Core.Copy.Op)() as Self; } } - impl as Core.EqWith(Square) { + impl as Core.Eq { fn Equal(self, other: Self) -> bool { - // TODO: Use a `char` comparison when it's supported. - return (self as u8) == (other as u8); - } - fn NotEqual(self, other: Self) -> bool { - // TODO: Use a `char` comparison when it's supported. - return (self as u8) != (other as u8); + return (self as char) == (other as char); } } diff --git a/examples/advent2024/day4_common.carbon b/examples/advent2024/day4_common.carbon index 681ae1f977bc..348949d727c5 100644 --- a/examples/advent2024/day4_common.carbon +++ b/examples/advent2024/day4_common.carbon @@ -13,18 +13,13 @@ class Wordsearch { fn Read() -> Wordsearch { returned var s: Wordsearch; - // TODO: Use for loops once they're implemented. - var y: i32 = 0; - while (y < 140) { - var x: i32 = 0; - while (x < 140) { + for (y: i32 in Core.Range(140)) { + for (x: i32 in Core.Range(140)) { // TODO: Assert on failure. s.grid[x][y] = ReadChar() as i32; - ++x; } // TODO: Assert on failure. SkipNewline(); - ++y; } return var; } @@ -33,25 +28,12 @@ class Wordsearch { return if x < 0 or x >= 140 or y < 0 or y >= 140 then -1 else self.grid[x][y]; } - // TODO: Make this generic in the length of the search query. - fn Check4(self, xmas: array(i32, 4), x: i32, y: i32, dx: i32, dy: i32) -> bool { - var i: i32 = 0; - while (i < 4) { + // TODO: Deduce N. + fn Check(self, generic N: i32, xmas: array(i32, N), x: i32, y: i32, dx: i32, dy: i32) -> bool { + for (i: i32 in Core.Range(N)) { if (self.At(x + i * dx, y + i * dy) != xmas[i]) { return false; } - ++i; - } - return true; - } - - fn Check3(self, mas: array(i32, 3), x: i32, y: i32, dx: i32, dy: i32) -> bool { - var i: i32 = 0; - while (i < 3) { - if (self.At(x + i * dx, y + i * dy) != mas[i]) { - return false; - } - ++i; } return true; } diff --git a/examples/advent2024/day4_part1.carbon b/examples/advent2024/day4_part1.carbon index 9a86afd6cc0d..dfa250893ef3 100644 --- a/examples/advent2024/day4_part1.carbon +++ b/examples/advent2024/day4_part1.carbon @@ -18,7 +18,7 @@ fn Run() { for (x: i32 in Core.Range(140)) { for (dy: i32 in Core.InclusiveRange(-1, 1)) { for (dx: i32 in Core.InclusiveRange(-1, 1)) { - if (search.Check4(xmas, x, y, dx, dy)) { + if (search.Check(4, xmas, x, y, dx, dy)) { ++found; } } diff --git a/examples/advent2024/day4_part2.carbon b/examples/advent2024/day4_part2.carbon index 94789fce86ad..8b3e17b3236b 100644 --- a/examples/advent2024/day4_part2.carbon +++ b/examples/advent2024/day4_part2.carbon @@ -16,10 +16,10 @@ fn Run() { for (y: i32 in Core.InclusiveRange(1, 138)) { for (x: i32 in Core.InclusiveRange(1, 138)) { - if ((search.Check3(mas, x - 1, y - 1, 1, 1) or - search.Check3(mas, x + 1, y + 1, -1, -1)) and - (search.Check3(mas, x - 1, y + 1, 1, -1) or - search.Check3(mas, x + 1, y - 1, -1, 1))) { + if ((search.Check(3, mas, x - 1, y - 1, 1, 1) or + search.Check(3, mas, x + 1, y + 1, -1, -1)) and + (search.Check(3, mas, x - 1, y + 1, 1, -1) or + search.Check(3, mas, x + 1, y - 1, -1, 1))) { ++found; } } diff --git a/examples/advent2024/io_utils.carbon b/examples/advent2024/io_utils.carbon index 7f8134e0ed06..7bd2fb3eb3e6 100644 --- a/examples/advent2024/io_utils.carbon +++ b/examples/advent2024/io_utils.carbon @@ -85,8 +85,7 @@ fn ReadChar() -> CharOrEOF { fn UnreadChar(c: CharOrEOF) { // TODO: assert(unread_char == 0); - // TODO: unread_char = c; - unread_char = Core.Optional(CharOrEOF).Some(c); + unread_char = c; } fn PeekChar() -> CharOrEOF { diff --git a/examples/advent2024/sort.carbon b/examples/advent2024/sort.carbon index 7027a72c55fd..c8fd35d40c95 100644 --- a/examples/advent2024/sort.carbon +++ b/examples/advent2024/sort.carbon @@ -4,21 +4,6 @@ library "sort"; -interface Ordered { - // extend require impls Core.OrderedWith(Self); - fn Less(self, other: Self) -> bool; - fn LessOrEquivalent(self, other: Self) -> bool; - fn Greater(self, other: Self) -> bool; - fn GreaterOrEquivalent(self, other: Self) -> bool; -} - -impl i32 as Ordered { - fn Less(self, other: Self) -> bool { return self < other; } - fn LessOrEquivalent(self, other: Self) -> bool { return self <= other; } - fn Greater(self, other: Self) -> bool { return self > other; } - fn GreaterOrEquivalent(self, other: Self) -> bool { return self >= other; } -} - fn Swap[T: Core.Copy & Core.Destroy](ref from: T, ref to: T) { var tmp: T = from; from = to; @@ -26,18 +11,16 @@ fn Swap[T: Core.Copy & Core.Destroy](ref from: T, ref to: T) { } fn Partition - [T: Core.Copy & Core.Destroy & Ordered, N: Core.IntLiteral] + [T: Core.Copy & Core.Destroy & Core.Ordered, N: Core.IntLiteral] (ref a: array(T, N), from_in: i32, to_in: i32) -> i32 { var pivot_index: i32 = from_in; let pivot: T = a[pivot_index]; var from: i32 = from_in + 1; var to: i32 = to_in; while (from < to) { - // TODO: if (a[from] <= pivot) { - if (a[from].(Ordered.LessOrEquivalent)(pivot)) { + if (a[from] <= pivot) { ++from; - // TODO: } else if ((*p)[to - 1] > pivot) { - } else if (a[to - 1].(Ordered.Greater)(pivot)) { + } else if (a[to - 1] > pivot) { --to; } else { // Element at `from` is > pivot, and @@ -52,7 +35,7 @@ fn Partition } fn Quicksort - [T: Core.Copy & Core.Destroy & Ordered, N: Core.IntLiteral] + [T: Core.Copy & Core.Destroy & Core.Ordered, N: Core.IntLiteral] (ref a: array(T, N), from: i32, to: i32) { if (from + 1 >= to) { return; } var pivot: i32 = Partition(ref a, from, to); diff --git a/toolchain/check/testdata/interop/cpp/operators/eq_with.carbon b/toolchain/check/testdata/interop/cpp/operators/eq_with.carbon index a420473609a9..4578178b922a 100644 --- a/toolchain/check/testdata/interop/cpp/operators/eq_with.carbon +++ b/toolchain/check/testdata/interop/cpp/operators/eq_with.carbon @@ -99,9 +99,9 @@ struct NeqBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+6]]:8: note: type `i32` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator!=(NeqBoolish) const -> int; // CHECK:STDERR: ^ - // CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:20:3: note: while building thunk to match the signature of this function [ThunkSignature] - // CHECK:STDERR: fn NotEqual(self, other: Other) -> bool; - // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:14:3: note: while building thunk to match the signature of this function [ThunkSignature] + // CHECK:STDERR: default fn NotEqual(self, other: Other) -> bool { + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ auto operator!=(NeqBoolish) const -> int; }; @@ -130,7 +130,7 @@ struct BothBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-21]]:8: note: type `Core.Optional(i32* as Core.OptionalStorage)` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator==(EqBoolish) const -> int*; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:19:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:13:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn Equal(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+30]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] @@ -143,7 +143,7 @@ struct BothBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-25]]:8: note: type `Cpp.Result` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator==(BothBoolish) const -> Result; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:19:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:13:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn Equal(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+17]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] @@ -156,9 +156,9 @@ struct BothBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-37]]:8: note: type `Cpp.Result` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator!=(BothBoolish) const -> Result; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:20:3: note: while building thunk to match the signature of this function [ThunkSignature] -// CHECK:STDERR: fn NotEqual(self, other: Other) -> bool; -// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:14:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: default fn NotEqual(self, other: Other) -> bool { +// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+4]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] // CHECK:STDERR: fn EqWith[U: type, T: Core.EqWith(U)](x: T, y: U) { // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -385,17 +385,17 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: %EqWith.assoc_type.85b122.2: type = assoc_entity_type @EqWith.1, @EqWith.1(%U) [symbolic] // CHECK:STDOUT: %assoc0.eee873.2: %EqWith.assoc_type.85b122.2 = assoc_entity element0, imports.%Core.import_ref.5ba [symbolic] // CHECK:STDOUT: %assoc1.0ffc88.2: %EqWith.assoc_type.85b122.2 = assoc_entity element1, imports.%Core.import_ref.03f [symbolic] -// CHECK:STDOUT: %require_complete.fb5: = require_complete_type %EqWith.type.98ea86.2 [symbolic] -// CHECK:STDOUT: %assoc0.d00: %EqWith.assoc_type.85b122.1 = assoc_entity element0, imports.%Core.import_ref.2e5 [symbolic] -// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T, @EqWith.1, @EqWith.1(%U) [symbolic] +// CHECK:STDOUT: %require_complete.fb534a.2: = require_complete_type %EqWith.type.98ea86.2 [symbolic] +// CHECK:STDOUT: %assoc0.d00a4a.3: %EqWith.assoc_type.85b122.1 = assoc_entity element0, imports.%Core.import_ref.2e55e8.3 [symbolic] +// CHECK:STDOUT: %EqWith.lookup_impl_witness.8c86eb.2: = lookup_impl_witness %T, @EqWith.1, @EqWith.1(%U) [symbolic] // CHECK:STDOUT: %EqWith.WithSelf.Equal.type.b82ec7.3: type = fn_type @EqWith.WithSelf.Equal, @EqWith.WithSelf(%U, %T) [symbolic] // CHECK:STDOUT: %EqWith.WithSelf.NotEqual.type.c5b45a.3: type = fn_type @EqWith.WithSelf.NotEqual, @EqWith.WithSelf(%U, %T) [symbolic] -// CHECK:STDOUT: %.74c: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type.b82ec7.3, %T [symbolic] -// CHECK:STDOUT: %impl.elem0: %.74c = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic] -// CHECK:STDOUT: %specific_impl_fn.67a: = specific_impl_function %impl.elem0, @EqWith.WithSelf.Equal(%U, %T) [symbolic] -// CHECK:STDOUT: %assoc1.d80: %EqWith.assoc_type.85b122.1 = assoc_entity element1, imports.%Core.import_ref.b78 [symbolic] +// CHECK:STDOUT: %.74c594.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type.b82ec7.3, %T [symbolic] +// CHECK:STDOUT: %impl.elem0.cab41a.2: %.74c594.2 = impl_witness_access %EqWith.lookup_impl_witness.8c86eb.2, element0 [symbolic] +// CHECK:STDOUT: %specific_impl_fn.67a2b4.2: = specific_impl_function %impl.elem0.cab41a.2, @EqWith.WithSelf.Equal(%U, %T) [symbolic] +// CHECK:STDOUT: %assoc1.d80b29.2: %EqWith.assoc_type.85b122.1 = assoc_entity element1, imports.%Core.import_ref.b78c91.2 [symbolic] // CHECK:STDOUT: %.8ed: type = fn_type_with_self_type %EqWith.WithSelf.NotEqual.type.c5b45a.3, %T [symbolic] -// CHECK:STDOUT: %impl.elem1: %.8ed = impl_witness_access %EqWith.lookup_impl_witness, element1 [symbolic] +// CHECK:STDOUT: %impl.elem1: %.8ed = impl_witness_access %EqWith.lookup_impl_witness.8c86eb.2, element1 [symbolic] // CHECK:STDOUT: %specific_impl_fn.81f: = specific_impl_function %impl.elem1, @EqWith.WithSelf.NotEqual(%U, %T) [symbolic] // CHECK:STDOUT: %EqualityComparable: type = class_type @EqualityComparable [concrete] // CHECK:STDOUT: %pattern_type.73b: type = pattern_type %EqualityComparable [concrete] @@ -425,12 +425,12 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core.import_ref.725: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc0 (constants.%assoc0.d00)] -// CHECK:STDOUT: %Core.import_ref.8d7: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc1 (constants.%assoc1.d80)] +// CHECK:STDOUT: %Core.import_ref.725: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc0 (constants.%assoc0.d00a4a.3)] +// CHECK:STDOUT: %Core.import_ref.8d7: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc1 (constants.%assoc1.d80b29.2)] // CHECK:STDOUT: %Core.import_ref.03f: @EqWith.WithSelf.%EqWith.WithSelf.NotEqual.type (%EqWith.WithSelf.NotEqual.type.c5b45a.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%EqWith.WithSelf.NotEqual (constants.%EqWith.WithSelf.NotEqual.b4230d.1)] // CHECK:STDOUT: %Core.import_ref.5ba: @EqWith.WithSelf.%EqWith.WithSelf.Equal.type (%EqWith.WithSelf.Equal.type.b82ec7.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%EqWith.WithSelf.Equal (constants.%EqWith.WithSelf.Equal.ae3c3e.1)] -// CHECK:STDOUT: %Core.import_ref.2e5 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded -// CHECK:STDOUT: %Core.import_ref.b78 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded +// CHECK:STDOUT: %Core.import_ref.2e55e8.3 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded +// CHECK:STDOUT: %Core.import_ref.b78c91.2 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @EqWith.loc11(%U.loc11_12.2: type, %T.loc11_21.2: @EqWith.loc11.%EqWith.type.loc11_36.1 (%EqWith.type.98ea86.2)) { @@ -438,14 +438,14 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: -// CHECK:STDOUT: %require_complete.loc13: = require_complete_type %EqWith.type.loc11_36.1 [symbolic = %require_complete.loc13 (constants.%require_complete.fb5)] +// CHECK:STDOUT: %require_complete.loc13: = require_complete_type %EqWith.type.loc11_36.1 [symbolic = %require_complete.loc13 (constants.%require_complete.fb534a.2)] // CHECK:STDOUT: %EqWith.assoc_type: type = assoc_entity_type @EqWith.1, @EqWith.1(%U.loc11_12.1) [symbolic = %EqWith.assoc_type (constants.%EqWith.assoc_type.85b122.2)] // CHECK:STDOUT: %assoc0: @EqWith.loc11.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = assoc_entity element0, imports.%Core.import_ref.5ba [symbolic = %assoc0 (constants.%assoc0.eee873.2)] // CHECK:STDOUT: %EqWith.WithSelf.Equal.type: type = fn_type @EqWith.WithSelf.Equal, @EqWith.WithSelf(%U.loc11_12.1, %T.loc11_21.1) [symbolic = %EqWith.WithSelf.Equal.type (constants.%EqWith.WithSelf.Equal.type.b82ec7.3)] -// CHECK:STDOUT: %.loc13_5.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type, %T.loc11_21.1 [symbolic = %.loc13_5.2 (constants.%.74c)] -// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T.loc11_21.1, @EqWith.1, @EqWith.1(%U.loc11_12.1) [symbolic = %EqWith.lookup_impl_witness (constants.%EqWith.lookup_impl_witness)] -// CHECK:STDOUT: %impl.elem0.loc13_5.2: @EqWith.loc11.%.loc13_5.2 (%.74c) = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc13_5.2 (constants.%impl.elem0)] -// CHECK:STDOUT: %specific_impl_fn.loc13_5.2: = specific_impl_function %impl.elem0.loc13_5.2, @EqWith.WithSelf.Equal(%U.loc11_12.1, %T.loc11_21.1) [symbolic = %specific_impl_fn.loc13_5.2 (constants.%specific_impl_fn.67a)] +// CHECK:STDOUT: %.loc13_5.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type, %T.loc11_21.1 [symbolic = %.loc13_5.2 (constants.%.74c594.2)] +// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T.loc11_21.1, @EqWith.1, @EqWith.1(%U.loc11_12.1) [symbolic = %EqWith.lookup_impl_witness (constants.%EqWith.lookup_impl_witness.8c86eb.2)] +// CHECK:STDOUT: %impl.elem0.loc13_5.2: @EqWith.loc11.%.loc13_5.2 (%.74c594.2) = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc13_5.2 (constants.%impl.elem0.cab41a.2)] +// CHECK:STDOUT: %specific_impl_fn.loc13_5.2: = specific_impl_function %impl.elem0.loc13_5.2, @EqWith.WithSelf.Equal(%U.loc11_12.1, %T.loc11_21.1) [symbolic = %specific_impl_fn.loc13_5.2 (constants.%specific_impl_fn.67a2b4.2)] // CHECK:STDOUT: %assoc1: @EqWith.loc11.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = assoc_entity element1, imports.%Core.import_ref.03f [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] // CHECK:STDOUT: %EqWith.WithSelf.NotEqual.type: type = fn_type @EqWith.WithSelf.NotEqual, @EqWith.WithSelf(%U.loc11_12.1, %T.loc11_21.1) [symbolic = %EqWith.WithSelf.NotEqual.type (constants.%EqWith.WithSelf.NotEqual.type.c5b45a.3)] // CHECK:STDOUT: %.loc14_5.2: type = fn_type_with_self_type %EqWith.WithSelf.NotEqual.type, %T.loc11_21.1 [symbolic = %.loc14_5.2 (constants.%.8ed)] @@ -459,9 +459,9 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: %EqWith.type.loc13: type = facet_type <@EqWith.1, @EqWith.1(constants.%U)> [symbolic = %EqWith.type.loc11_36.1 (constants.%EqWith.type.98ea86.2)] // CHECK:STDOUT: %.loc13_5.1: @EqWith.loc11.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = specific_constant imports.%Core.import_ref.725, @EqWith.WithSelf(constants.%U, constants.%Self.d94ae0.1) [symbolic = %assoc0 (constants.%assoc0.eee873.2)] // CHECK:STDOUT: %Equal.ref: @EqWith.loc11.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = name_ref Equal, %.loc13_5.1 [symbolic = %assoc0 (constants.%assoc0.eee873.2)] -// CHECK:STDOUT: %impl.elem0.loc13_5.1: @EqWith.loc11.%.loc13_5.2 (%.74c) = impl_witness_access constants.%EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc13_5.2 (constants.%impl.elem0)] +// CHECK:STDOUT: %impl.elem0.loc13_5.1: @EqWith.loc11.%.loc13_5.2 (%.74c594.2) = impl_witness_access constants.%EqWith.lookup_impl_witness.8c86eb.2, element0 [symbolic = %impl.elem0.loc13_5.2 (constants.%impl.elem0.cab41a.2)] // CHECK:STDOUT: %bound_method.loc13_5.1: = bound_method %x.ref.loc13, %impl.elem0.loc13_5.1 -// CHECK:STDOUT: %specific_impl_fn.loc13_5.1: = specific_impl_function %impl.elem0.loc13_5.1, @EqWith.WithSelf.Equal(constants.%U, constants.%T) [symbolic = %specific_impl_fn.loc13_5.2 (constants.%specific_impl_fn.67a)] +// CHECK:STDOUT: %specific_impl_fn.loc13_5.1: = specific_impl_function %impl.elem0.loc13_5.1, @EqWith.WithSelf.Equal(constants.%U, constants.%T) [symbolic = %specific_impl_fn.loc13_5.2 (constants.%specific_impl_fn.67a2b4.2)] // CHECK:STDOUT: %bound_method.loc13_5.2: = bound_method %x.ref.loc13, %specific_impl_fn.loc13_5.1 // CHECK:STDOUT: %EqWith.WithSelf.Equal.call: init bool = call %bound_method.loc13_5.2(%x.ref.loc13, %y.ref.loc13) // CHECK:STDOUT: %x.ref.loc14: @EqWith.loc11.%T.as_type.loc11_42.1 (%T.as_type) = name_ref x, %x @@ -469,7 +469,7 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: %EqWith.type.loc14: type = facet_type <@EqWith.1, @EqWith.1(constants.%U)> [symbolic = %EqWith.type.loc11_36.1 (constants.%EqWith.type.98ea86.2)] // CHECK:STDOUT: %.loc14_5.1: @EqWith.loc11.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = specific_constant imports.%Core.import_ref.8d7, @EqWith.WithSelf(constants.%U, constants.%Self.d94ae0.1) [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] // CHECK:STDOUT: %NotEqual.ref: @EqWith.loc11.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = name_ref NotEqual, %.loc14_5.1 [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] -// CHECK:STDOUT: %impl.elem1.loc14_5.1: @EqWith.loc11.%.loc14_5.2 (%.8ed) = impl_witness_access constants.%EqWith.lookup_impl_witness, element1 [symbolic = %impl.elem1.loc14_5.2 (constants.%impl.elem1)] +// CHECK:STDOUT: %impl.elem1.loc14_5.1: @EqWith.loc11.%.loc14_5.2 (%.8ed) = impl_witness_access constants.%EqWith.lookup_impl_witness.8c86eb.2, element1 [symbolic = %impl.elem1.loc14_5.2 (constants.%impl.elem1)] // CHECK:STDOUT: %bound_method.loc14_5.1: = bound_method %x.ref.loc14, %impl.elem1.loc14_5.1 // CHECK:STDOUT: %specific_impl_fn.loc14_5.1: = specific_impl_function %impl.elem1.loc14_5.1, @EqWith.WithSelf.NotEqual(constants.%U, constants.%T) [symbolic = %specific_impl_fn.loc14_5.2 (constants.%specific_impl_fn.81f)] // CHECK:STDOUT: %bound_method.loc14_5.2: = bound_method %x.ref.loc14, %specific_impl_fn.loc14_5.1 @@ -555,17 +555,17 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: %EqWith.assoc_type.85b122.2: type = assoc_entity_type @EqWith.1, @EqWith.1(%U) [symbolic] // CHECK:STDOUT: %assoc0.eee873.2: %EqWith.assoc_type.85b122.2 = assoc_entity element0, imports.%Core.import_ref.5ba [symbolic] // CHECK:STDOUT: %assoc1.0ffc88.2: %EqWith.assoc_type.85b122.2 = assoc_entity element1, imports.%Core.import_ref.03f [symbolic] -// CHECK:STDOUT: %require_complete.fb5: = require_complete_type %EqWith.type.98ea86.2 [symbolic] -// CHECK:STDOUT: %assoc0.d00: %EqWith.assoc_type.85b122.1 = assoc_entity element0, imports.%Core.import_ref.2e5 [symbolic] -// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T, @EqWith.1, @EqWith.1(%U) [symbolic] +// CHECK:STDOUT: %require_complete.fb534a.2: = require_complete_type %EqWith.type.98ea86.2 [symbolic] +// CHECK:STDOUT: %assoc0.d00a4a.3: %EqWith.assoc_type.85b122.1 = assoc_entity element0, imports.%Core.import_ref.2e55e8.3 [symbolic] +// CHECK:STDOUT: %EqWith.lookup_impl_witness.8c86eb.2: = lookup_impl_witness %T, @EqWith.1, @EqWith.1(%U) [symbolic] // CHECK:STDOUT: %EqWith.WithSelf.Equal.type.b82ec7.3: type = fn_type @EqWith.WithSelf.Equal, @EqWith.WithSelf(%U, %T) [symbolic] // CHECK:STDOUT: %EqWith.WithSelf.NotEqual.type.c5b45a.3: type = fn_type @EqWith.WithSelf.NotEqual, @EqWith.WithSelf(%U, %T) [symbolic] -// CHECK:STDOUT: %.74c: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type.b82ec7.3, %T [symbolic] -// CHECK:STDOUT: %impl.elem0: %.74c = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic] -// CHECK:STDOUT: %specific_impl_fn.67a: = specific_impl_function %impl.elem0, @EqWith.WithSelf.Equal(%U, %T) [symbolic] -// CHECK:STDOUT: %assoc1.d80: %EqWith.assoc_type.85b122.1 = assoc_entity element1, imports.%Core.import_ref.b78 [symbolic] +// CHECK:STDOUT: %.74c594.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type.b82ec7.3, %T [symbolic] +// CHECK:STDOUT: %impl.elem0.cab41a.2: %.74c594.2 = impl_witness_access %EqWith.lookup_impl_witness.8c86eb.2, element0 [symbolic] +// CHECK:STDOUT: %specific_impl_fn.67a2b4.2: = specific_impl_function %impl.elem0.cab41a.2, @EqWith.WithSelf.Equal(%U, %T) [symbolic] +// CHECK:STDOUT: %assoc1.d80b29.2: %EqWith.assoc_type.85b122.1 = assoc_entity element1, imports.%Core.import_ref.b78c91.2 [symbolic] // CHECK:STDOUT: %.8ed: type = fn_type_with_self_type %EqWith.WithSelf.NotEqual.type.c5b45a.3, %T [symbolic] -// CHECK:STDOUT: %impl.elem1: %.8ed = impl_witness_access %EqWith.lookup_impl_witness, element1 [symbolic] +// CHECK:STDOUT: %impl.elem1: %.8ed = impl_witness_access %EqWith.lookup_impl_witness.8c86eb.2, element1 [symbolic] // CHECK:STDOUT: %specific_impl_fn.81f: = specific_impl_function %impl.elem1, @EqWith.WithSelf.NotEqual(%U, %T) [symbolic] // CHECK:STDOUT: %A1: type = class_type @A1 [concrete] // CHECK:STDOUT: %pattern_type.3b4: type = pattern_type %A1 [concrete] @@ -689,12 +689,12 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core.import_ref.725: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc0 (constants.%assoc0.d00)] -// CHECK:STDOUT: %Core.import_ref.8d7: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc1 (constants.%assoc1.d80)] +// CHECK:STDOUT: %Core.import_ref.725: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc0 (constants.%assoc0.d00a4a.3)] +// CHECK:STDOUT: %Core.import_ref.8d7: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc1 (constants.%assoc1.d80b29.2)] // CHECK:STDOUT: %Core.import_ref.03f: @EqWith.WithSelf.%EqWith.WithSelf.NotEqual.type (%EqWith.WithSelf.NotEqual.type.c5b45a.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%EqWith.WithSelf.NotEqual (constants.%EqWith.WithSelf.NotEqual.b4230d.1)] // CHECK:STDOUT: %Core.import_ref.5ba: @EqWith.WithSelf.%EqWith.WithSelf.Equal.type (%EqWith.WithSelf.Equal.type.b82ec7.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%EqWith.WithSelf.Equal (constants.%EqWith.WithSelf.Equal.ae3c3e.1)] -// CHECK:STDOUT: %Core.import_ref.2e5 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded -// CHECK:STDOUT: %Core.import_ref.b78 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded +// CHECK:STDOUT: %Core.import_ref.2e55e8.3 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded +// CHECK:STDOUT: %Core.import_ref.b78c91.2 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @EqWith.loc34(%U.loc34_12.2: type, %T.loc34_21.2: @EqWith.loc34.%EqWith.type.loc34_36.1 (%EqWith.type.98ea86.2)) { @@ -702,14 +702,14 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: -// CHECK:STDOUT: %require_complete.loc36: = require_complete_type %EqWith.type.loc34_36.1 [symbolic = %require_complete.loc36 (constants.%require_complete.fb5)] +// CHECK:STDOUT: %require_complete.loc36: = require_complete_type %EqWith.type.loc34_36.1 [symbolic = %require_complete.loc36 (constants.%require_complete.fb534a.2)] // CHECK:STDOUT: %EqWith.assoc_type: type = assoc_entity_type @EqWith.1, @EqWith.1(%U.loc34_12.1) [symbolic = %EqWith.assoc_type (constants.%EqWith.assoc_type.85b122.2)] // CHECK:STDOUT: %assoc0: @EqWith.loc34.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = assoc_entity element0, imports.%Core.import_ref.5ba [symbolic = %assoc0 (constants.%assoc0.eee873.2)] // CHECK:STDOUT: %EqWith.WithSelf.Equal.type: type = fn_type @EqWith.WithSelf.Equal, @EqWith.WithSelf(%U.loc34_12.1, %T.loc34_21.1) [symbolic = %EqWith.WithSelf.Equal.type (constants.%EqWith.WithSelf.Equal.type.b82ec7.3)] -// CHECK:STDOUT: %.loc36_5.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type, %T.loc34_21.1 [symbolic = %.loc36_5.2 (constants.%.74c)] -// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T.loc34_21.1, @EqWith.1, @EqWith.1(%U.loc34_12.1) [symbolic = %EqWith.lookup_impl_witness (constants.%EqWith.lookup_impl_witness)] -// CHECK:STDOUT: %impl.elem0.loc36_5.2: @EqWith.loc34.%.loc36_5.2 (%.74c) = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc36_5.2 (constants.%impl.elem0)] -// CHECK:STDOUT: %specific_impl_fn.loc36_5.2: = specific_impl_function %impl.elem0.loc36_5.2, @EqWith.WithSelf.Equal(%U.loc34_12.1, %T.loc34_21.1) [symbolic = %specific_impl_fn.loc36_5.2 (constants.%specific_impl_fn.67a)] +// CHECK:STDOUT: %.loc36_5.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type, %T.loc34_21.1 [symbolic = %.loc36_5.2 (constants.%.74c594.2)] +// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T.loc34_21.1, @EqWith.1, @EqWith.1(%U.loc34_12.1) [symbolic = %EqWith.lookup_impl_witness (constants.%EqWith.lookup_impl_witness.8c86eb.2)] +// CHECK:STDOUT: %impl.elem0.loc36_5.2: @EqWith.loc34.%.loc36_5.2 (%.74c594.2) = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc36_5.2 (constants.%impl.elem0.cab41a.2)] +// CHECK:STDOUT: %specific_impl_fn.loc36_5.2: = specific_impl_function %impl.elem0.loc36_5.2, @EqWith.WithSelf.Equal(%U.loc34_12.1, %T.loc34_21.1) [symbolic = %specific_impl_fn.loc36_5.2 (constants.%specific_impl_fn.67a2b4.2)] // CHECK:STDOUT: %assoc1: @EqWith.loc34.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = assoc_entity element1, imports.%Core.import_ref.03f [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] // CHECK:STDOUT: %EqWith.WithSelf.NotEqual.type: type = fn_type @EqWith.WithSelf.NotEqual, @EqWith.WithSelf(%U.loc34_12.1, %T.loc34_21.1) [symbolic = %EqWith.WithSelf.NotEqual.type (constants.%EqWith.WithSelf.NotEqual.type.c5b45a.3)] // CHECK:STDOUT: %.loc37_5.2: type = fn_type_with_self_type %EqWith.WithSelf.NotEqual.type, %T.loc34_21.1 [symbolic = %.loc37_5.2 (constants.%.8ed)] @@ -723,9 +723,9 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: %EqWith.type.loc36: type = facet_type <@EqWith.1, @EqWith.1(constants.%U)> [symbolic = %EqWith.type.loc34_36.1 (constants.%EqWith.type.98ea86.2)] // CHECK:STDOUT: %.loc36_5.1: @EqWith.loc34.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = specific_constant imports.%Core.import_ref.725, @EqWith.WithSelf(constants.%U, constants.%Self.d94ae0.1) [symbolic = %assoc0 (constants.%assoc0.eee873.2)] // CHECK:STDOUT: %Equal.ref: @EqWith.loc34.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = name_ref Equal, %.loc36_5.1 [symbolic = %assoc0 (constants.%assoc0.eee873.2)] -// CHECK:STDOUT: %impl.elem0.loc36_5.1: @EqWith.loc34.%.loc36_5.2 (%.74c) = impl_witness_access constants.%EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc36_5.2 (constants.%impl.elem0)] +// CHECK:STDOUT: %impl.elem0.loc36_5.1: @EqWith.loc34.%.loc36_5.2 (%.74c594.2) = impl_witness_access constants.%EqWith.lookup_impl_witness.8c86eb.2, element0 [symbolic = %impl.elem0.loc36_5.2 (constants.%impl.elem0.cab41a.2)] // CHECK:STDOUT: %bound_method.loc36_5.1: = bound_method %x.ref.loc36, %impl.elem0.loc36_5.1 -// CHECK:STDOUT: %specific_impl_fn.loc36_5.1: = specific_impl_function %impl.elem0.loc36_5.1, @EqWith.WithSelf.Equal(constants.%U, constants.%T) [symbolic = %specific_impl_fn.loc36_5.2 (constants.%specific_impl_fn.67a)] +// CHECK:STDOUT: %specific_impl_fn.loc36_5.1: = specific_impl_function %impl.elem0.loc36_5.1, @EqWith.WithSelf.Equal(constants.%U, constants.%T) [symbolic = %specific_impl_fn.loc36_5.2 (constants.%specific_impl_fn.67a2b4.2)] // CHECK:STDOUT: %bound_method.loc36_5.2: = bound_method %x.ref.loc36, %specific_impl_fn.loc36_5.1 // CHECK:STDOUT: %EqWith.WithSelf.Equal.call: init bool = call %bound_method.loc36_5.2(%x.ref.loc36, %y.ref.loc36) // CHECK:STDOUT: %x.ref.loc37: @EqWith.loc34.%T.as_type.loc34_42.1 (%T.as_type) = name_ref x, %x @@ -733,7 +733,7 @@ fn Test(only_neq: Cpp.OnlyNeq, // CHECK:STDOUT: %EqWith.type.loc37: type = facet_type <@EqWith.1, @EqWith.1(constants.%U)> [symbolic = %EqWith.type.loc34_36.1 (constants.%EqWith.type.98ea86.2)] // CHECK:STDOUT: %.loc37_5.1: @EqWith.loc34.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = specific_constant imports.%Core.import_ref.8d7, @EqWith.WithSelf(constants.%U, constants.%Self.d94ae0.1) [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] // CHECK:STDOUT: %NotEqual.ref: @EqWith.loc34.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = name_ref NotEqual, %.loc37_5.1 [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] -// CHECK:STDOUT: %impl.elem1.loc37_5.1: @EqWith.loc34.%.loc37_5.2 (%.8ed) = impl_witness_access constants.%EqWith.lookup_impl_witness, element1 [symbolic = %impl.elem1.loc37_5.2 (constants.%impl.elem1)] +// CHECK:STDOUT: %impl.elem1.loc37_5.1: @EqWith.loc34.%.loc37_5.2 (%.8ed) = impl_witness_access constants.%EqWith.lookup_impl_witness.8c86eb.2, element1 [symbolic = %impl.elem1.loc37_5.2 (constants.%impl.elem1)] // CHECK:STDOUT: %bound_method.loc37_5.1: = bound_method %x.ref.loc37, %impl.elem1.loc37_5.1 // CHECK:STDOUT: %specific_impl_fn.loc37_5.1: = specific_impl_function %impl.elem1.loc37_5.1, @EqWith.WithSelf.NotEqual(constants.%U, constants.%T) [symbolic = %specific_impl_fn.loc37_5.2 (constants.%specific_impl_fn.81f)] // CHECK:STDOUT: %bound_method.loc37_5.2: = bound_method %x.ref.loc37, %specific_impl_fn.loc37_5.1 diff --git a/toolchain/check/testdata/interop/cpp/operators/ordered_with.carbon b/toolchain/check/testdata/interop/cpp/operators/ordered_with.carbon index c40f8a2abddc..090a8e54c488 100644 --- a/toolchain/check/testdata/interop/cpp/operators/ordered_with.carbon +++ b/toolchain/check/testdata/interop/cpp/operators/ordered_with.carbon @@ -124,7 +124,7 @@ struct LessReturnsBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+6]]:8: note: type `i32` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator<(LessReturnsBoolish) const -> int; // CHECK:STDERR: ^ - // CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:26:3: note: while building thunk to match the signature of this function [ThunkSignature] + // CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:28:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn Less(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ auto operator<(LessReturnsBoolish) const -> int; @@ -177,7 +177,7 @@ struct AllReturnBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-39]]:8: note: type `Core.Optional(i32* as Core.OptionalStorage)` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator<=(LessEqualReturnsBoolish) const -> int*; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:27:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:29:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn LessOrEquivalent(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+69]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] @@ -190,7 +190,7 @@ struct AllReturnBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-42]]:8: note: type `Cpp.Result` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator>=(GreaterEqualReturnsBoolish) const -> Result; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:29:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:31:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn GreaterOrEquivalent(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+56]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] @@ -203,7 +203,7 @@ struct AllReturnBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-40]]:8: note: type `f64` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator<(AllReturnBoolish) const -> double; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:26:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:28:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn Less(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+43]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] @@ -216,7 +216,7 @@ struct AllReturnBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-52]]:8: note: type `f64` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator<=(AllReturnBoolish) const -> double; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:27:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:29:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn LessOrEquivalent(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+30]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] @@ -229,7 +229,7 @@ struct AllReturnBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-64]]:8: note: type `f64` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator>(AllReturnBoolish) const -> double; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:28:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:30:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn Greater(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+17]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] @@ -242,7 +242,7 @@ struct AllReturnBoolish { // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE-76]]:8: note: type `f64` does not implement interface `Core.ImplicitAs(bool)` [MissingImplInMemberAccessInContext] // CHECK:STDERR: auto operator>=(AllReturnBoolish) const -> double; // CHECK:STDERR: ^ -// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:29:3: note: while building thunk to match the signature of this function [ThunkSignature] +// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:31:3: note: while building thunk to match the signature of this function [ThunkSignature] // CHECK:STDERR: fn GreaterOrEquivalent(self, other: Other) -> bool; // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_todo_returns_boolish.carbon:[[@LINE+4]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere] diff --git a/toolchain/check/testdata/interop/cpp/operators/spaceship.carbon b/toolchain/check/testdata/interop/cpp/operators/spaceship.carbon index 15ee3cbd278c..3e860219f63f 100644 --- a/toolchain/check/testdata/interop/cpp/operators/spaceship.carbon +++ b/toolchain/check/testdata/interop/cpp/operators/spaceship.carbon @@ -254,17 +254,17 @@ fn Test(returns_strong_ordering: Cpp.ReturnsStrongOrdering) { // CHECK:STDOUT: %EqWith.assoc_type.85b122.2: type = assoc_entity_type @EqWith.1, @EqWith.1(%U) [symbolic] // CHECK:STDOUT: %assoc0.eee873.2: %EqWith.assoc_type.85b122.2 = assoc_entity element0, imports.%Core.import_ref.5ba [symbolic] // CHECK:STDOUT: %assoc1.0ffc88.2: %EqWith.assoc_type.85b122.2 = assoc_entity element1, imports.%Core.import_ref.03f [symbolic] -// CHECK:STDOUT: %require_complete.fb5: = require_complete_type %EqWith.type.98ea86.2 [symbolic] -// CHECK:STDOUT: %assoc0.d00: %EqWith.assoc_type.85b122.1 = assoc_entity element0, imports.%Core.import_ref.2e5 [symbolic] -// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T.d94, @EqWith.1, @EqWith.1(%U) [symbolic] +// CHECK:STDOUT: %require_complete.fb534a.2: = require_complete_type %EqWith.type.98ea86.2 [symbolic] +// CHECK:STDOUT: %assoc0.d00a4a.3: %EqWith.assoc_type.85b122.1 = assoc_entity element0, imports.%Core.import_ref.2e55e8.3 [symbolic] +// CHECK:STDOUT: %EqWith.lookup_impl_witness.8c86eb.2: = lookup_impl_witness %T.d94, @EqWith.1, @EqWith.1(%U) [symbolic] // CHECK:STDOUT: %EqWith.WithSelf.Equal.type.b82ec7.3: type = fn_type @EqWith.WithSelf.Equal, @EqWith.WithSelf(%U, %T.d94) [symbolic] // CHECK:STDOUT: %EqWith.WithSelf.NotEqual.type.c5b45a.3: type = fn_type @EqWith.WithSelf.NotEqual, @EqWith.WithSelf(%U, %T.d94) [symbolic] -// CHECK:STDOUT: %.74c: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type.b82ec7.3, %T.d94 [symbolic] -// CHECK:STDOUT: %impl.elem0.cab: %.74c = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic] -// CHECK:STDOUT: %specific_impl_fn.67a: = specific_impl_function %impl.elem0.cab, @EqWith.WithSelf.Equal(%U, %T.d94) [symbolic] -// CHECK:STDOUT: %assoc1.d80: %EqWith.assoc_type.85b122.1 = assoc_entity element1, imports.%Core.import_ref.b78 [symbolic] +// CHECK:STDOUT: %.74c594.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type.b82ec7.3, %T.d94 [symbolic] +// CHECK:STDOUT: %impl.elem0.cab41a.2: %.74c594.2 = impl_witness_access %EqWith.lookup_impl_witness.8c86eb.2, element0 [symbolic] +// CHECK:STDOUT: %specific_impl_fn.67a2b4.2: = specific_impl_function %impl.elem0.cab41a.2, @EqWith.WithSelf.Equal(%U, %T.d94) [symbolic] +// CHECK:STDOUT: %assoc1.d80b29.2: %EqWith.assoc_type.85b122.1 = assoc_entity element1, imports.%Core.import_ref.b78c91.2 [symbolic] // CHECK:STDOUT: %.8ed: type = fn_type_with_self_type %EqWith.WithSelf.NotEqual.type.c5b45a.3, %T.d94 [symbolic] -// CHECK:STDOUT: %impl.elem1.dab: %.8ed = impl_witness_access %EqWith.lookup_impl_witness, element1 [symbolic] +// CHECK:STDOUT: %impl.elem1.dab: %.8ed = impl_witness_access %EqWith.lookup_impl_witness.8c86eb.2, element1 [symbolic] // CHECK:STDOUT: %specific_impl_fn.81f: = specific_impl_function %impl.elem1.dab, @EqWith.WithSelf.NotEqual(%U, %T.d94) [symbolic] // CHECK:STDOUT: %OrderedWith.type.32ae87.1: type = facet_type <@OrderedWith.1, @OrderedWith.1(%Other)> [symbolic] // CHECK:STDOUT: %Self.7df555.1: %OrderedWith.type.32ae87.1 = symbolic_binding Self, 1 [symbolic] @@ -353,12 +353,12 @@ fn Test(returns_strong_ordering: Cpp.ReturnsStrongOrdering) { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core.import_ref.725: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc0 (constants.%assoc0.d00)] -// CHECK:STDOUT: %Core.import_ref.8d7: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc1 (constants.%assoc1.d80)] +// CHECK:STDOUT: %Core.import_ref.725: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc0 (constants.%assoc0.d00a4a.3)] +// CHECK:STDOUT: %Core.import_ref.8d7: @EqWith.WithSelf.%EqWith.assoc_type (%EqWith.assoc_type.85b122.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%assoc1 (constants.%assoc1.d80b29.2)] // CHECK:STDOUT: %Core.import_ref.03f: @EqWith.WithSelf.%EqWith.WithSelf.NotEqual.type (%EqWith.WithSelf.NotEqual.type.c5b45a.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%EqWith.WithSelf.NotEqual (constants.%EqWith.WithSelf.NotEqual.b4230d.1)] // CHECK:STDOUT: %Core.import_ref.5ba: @EqWith.WithSelf.%EqWith.WithSelf.Equal.type (%EqWith.WithSelf.Equal.type.b82ec7.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @EqWith.WithSelf.%EqWith.WithSelf.Equal (constants.%EqWith.WithSelf.Equal.ae3c3e.1)] -// CHECK:STDOUT: %Core.import_ref.2e5 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded -// CHECK:STDOUT: %Core.import_ref.b78 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded +// CHECK:STDOUT: %Core.import_ref.2e55e8.3 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded +// CHECK:STDOUT: %Core.import_ref.b78c91.2 = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, unloaded // CHECK:STDOUT: %Core.import_ref.ef7: @OrderedWith.WithSelf.%OrderedWith.assoc_type (%OrderedWith.assoc_type.1d2e6f.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @OrderedWith.WithSelf.%assoc0 (constants.%assoc0.13c)] // CHECK:STDOUT: %Core.import_ref.878: @OrderedWith.WithSelf.%OrderedWith.assoc_type (%OrderedWith.assoc_type.1d2e6f.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @OrderedWith.WithSelf.%assoc1 (constants.%assoc1.ee7)] // CHECK:STDOUT: %Core.import_ref.d4f: @OrderedWith.WithSelf.%OrderedWith.assoc_type (%OrderedWith.assoc_type.1d2e6f.1) = import_ref Core//prelude/operators/comparison, loc{{\d+_\d+}}, loaded [symbolic = @OrderedWith.WithSelf.%assoc2 (constants.%assoc2.131)] @@ -378,14 +378,14 @@ fn Test(returns_strong_ordering: Cpp.ReturnsStrongOrdering) { // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: -// CHECK:STDOUT: %require_complete.loc6: = require_complete_type %EqWith.type.loc4_36.1 [symbolic = %require_complete.loc6 (constants.%require_complete.fb5)] +// CHECK:STDOUT: %require_complete.loc6: = require_complete_type %EqWith.type.loc4_36.1 [symbolic = %require_complete.loc6 (constants.%require_complete.fb534a.2)] // CHECK:STDOUT: %EqWith.assoc_type: type = assoc_entity_type @EqWith.1, @EqWith.1(%U.loc4_12.1) [symbolic = %EqWith.assoc_type (constants.%EqWith.assoc_type.85b122.2)] // CHECK:STDOUT: %assoc0: @EqWith.loc4.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = assoc_entity element0, imports.%Core.import_ref.5ba [symbolic = %assoc0 (constants.%assoc0.eee873.2)] // CHECK:STDOUT: %EqWith.WithSelf.Equal.type: type = fn_type @EqWith.WithSelf.Equal, @EqWith.WithSelf(%U.loc4_12.1, %T.loc4_21.1) [symbolic = %EqWith.WithSelf.Equal.type (constants.%EqWith.WithSelf.Equal.type.b82ec7.3)] -// CHECK:STDOUT: %.loc6_5.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type, %T.loc4_21.1 [symbolic = %.loc6_5.2 (constants.%.74c)] -// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T.loc4_21.1, @EqWith.1, @EqWith.1(%U.loc4_12.1) [symbolic = %EqWith.lookup_impl_witness (constants.%EqWith.lookup_impl_witness)] -// CHECK:STDOUT: %impl.elem0.loc6_5.2: @EqWith.loc4.%.loc6_5.2 (%.74c) = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc6_5.2 (constants.%impl.elem0.cab)] -// CHECK:STDOUT: %specific_impl_fn.loc6_5.2: = specific_impl_function %impl.elem0.loc6_5.2, @EqWith.WithSelf.Equal(%U.loc4_12.1, %T.loc4_21.1) [symbolic = %specific_impl_fn.loc6_5.2 (constants.%specific_impl_fn.67a)] +// CHECK:STDOUT: %.loc6_5.2: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type, %T.loc4_21.1 [symbolic = %.loc6_5.2 (constants.%.74c594.2)] +// CHECK:STDOUT: %EqWith.lookup_impl_witness: = lookup_impl_witness %T.loc4_21.1, @EqWith.1, @EqWith.1(%U.loc4_12.1) [symbolic = %EqWith.lookup_impl_witness (constants.%EqWith.lookup_impl_witness.8c86eb.2)] +// CHECK:STDOUT: %impl.elem0.loc6_5.2: @EqWith.loc4.%.loc6_5.2 (%.74c594.2) = impl_witness_access %EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc6_5.2 (constants.%impl.elem0.cab41a.2)] +// CHECK:STDOUT: %specific_impl_fn.loc6_5.2: = specific_impl_function %impl.elem0.loc6_5.2, @EqWith.WithSelf.Equal(%U.loc4_12.1, %T.loc4_21.1) [symbolic = %specific_impl_fn.loc6_5.2 (constants.%specific_impl_fn.67a2b4.2)] // CHECK:STDOUT: %assoc1: @EqWith.loc4.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = assoc_entity element1, imports.%Core.import_ref.03f [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] // CHECK:STDOUT: %EqWith.WithSelf.NotEqual.type: type = fn_type @EqWith.WithSelf.NotEqual, @EqWith.WithSelf(%U.loc4_12.1, %T.loc4_21.1) [symbolic = %EqWith.WithSelf.NotEqual.type (constants.%EqWith.WithSelf.NotEqual.type.c5b45a.3)] // CHECK:STDOUT: %.loc7_5.2: type = fn_type_with_self_type %EqWith.WithSelf.NotEqual.type, %T.loc4_21.1 [symbolic = %.loc7_5.2 (constants.%.8ed)] @@ -399,9 +399,9 @@ fn Test(returns_strong_ordering: Cpp.ReturnsStrongOrdering) { // CHECK:STDOUT: %EqWith.type.loc6: type = facet_type <@EqWith.1, @EqWith.1(constants.%U)> [symbolic = %EqWith.type.loc4_36.1 (constants.%EqWith.type.98ea86.2)] // CHECK:STDOUT: %.loc6_5.1: @EqWith.loc4.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = specific_constant imports.%Core.import_ref.725, @EqWith.WithSelf(constants.%U, constants.%Self.d94ae0.1) [symbolic = %assoc0 (constants.%assoc0.eee873.2)] // CHECK:STDOUT: %Equal.ref: @EqWith.loc4.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = name_ref Equal, %.loc6_5.1 [symbolic = %assoc0 (constants.%assoc0.eee873.2)] -// CHECK:STDOUT: %impl.elem0.loc6_5.1: @EqWith.loc4.%.loc6_5.2 (%.74c) = impl_witness_access constants.%EqWith.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc6_5.2 (constants.%impl.elem0.cab)] +// CHECK:STDOUT: %impl.elem0.loc6_5.1: @EqWith.loc4.%.loc6_5.2 (%.74c594.2) = impl_witness_access constants.%EqWith.lookup_impl_witness.8c86eb.2, element0 [symbolic = %impl.elem0.loc6_5.2 (constants.%impl.elem0.cab41a.2)] // CHECK:STDOUT: %bound_method.loc6_5.1: = bound_method %x.ref.loc6, %impl.elem0.loc6_5.1 -// CHECK:STDOUT: %specific_impl_fn.loc6_5.1: = specific_impl_function %impl.elem0.loc6_5.1, @EqWith.WithSelf.Equal(constants.%U, constants.%T.d94) [symbolic = %specific_impl_fn.loc6_5.2 (constants.%specific_impl_fn.67a)] +// CHECK:STDOUT: %specific_impl_fn.loc6_5.1: = specific_impl_function %impl.elem0.loc6_5.1, @EqWith.WithSelf.Equal(constants.%U, constants.%T.d94) [symbolic = %specific_impl_fn.loc6_5.2 (constants.%specific_impl_fn.67a2b4.2)] // CHECK:STDOUT: %bound_method.loc6_5.2: = bound_method %x.ref.loc6, %specific_impl_fn.loc6_5.1 // CHECK:STDOUT: %EqWith.WithSelf.Equal.call: init bool = call %bound_method.loc6_5.2(%x.ref.loc6, %y.ref.loc6) // CHECK:STDOUT: %x.ref.loc7: @EqWith.loc4.%T.as_type.loc4_42.1 (%T.as_type.93d) = name_ref x, %x @@ -409,7 +409,7 @@ fn Test(returns_strong_ordering: Cpp.ReturnsStrongOrdering) { // CHECK:STDOUT: %EqWith.type.loc7: type = facet_type <@EqWith.1, @EqWith.1(constants.%U)> [symbolic = %EqWith.type.loc4_36.1 (constants.%EqWith.type.98ea86.2)] // CHECK:STDOUT: %.loc7_5.1: @EqWith.loc4.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = specific_constant imports.%Core.import_ref.8d7, @EqWith.WithSelf(constants.%U, constants.%Self.d94ae0.1) [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] // CHECK:STDOUT: %NotEqual.ref: @EqWith.loc4.%EqWith.assoc_type (%EqWith.assoc_type.85b122.2) = name_ref NotEqual, %.loc7_5.1 [symbolic = %assoc1 (constants.%assoc1.0ffc88.2)] -// CHECK:STDOUT: %impl.elem1.loc7_5.1: @EqWith.loc4.%.loc7_5.2 (%.8ed) = impl_witness_access constants.%EqWith.lookup_impl_witness, element1 [symbolic = %impl.elem1.loc7_5.2 (constants.%impl.elem1.dab)] +// CHECK:STDOUT: %impl.elem1.loc7_5.1: @EqWith.loc4.%.loc7_5.2 (%.8ed) = impl_witness_access constants.%EqWith.lookup_impl_witness.8c86eb.2, element1 [symbolic = %impl.elem1.loc7_5.2 (constants.%impl.elem1.dab)] // CHECK:STDOUT: %bound_method.loc7_5.1: = bound_method %x.ref.loc7, %impl.elem1.loc7_5.1 // CHECK:STDOUT: %specific_impl_fn.loc7_5.1: = specific_impl_function %impl.elem1.loc7_5.1, @EqWith.WithSelf.NotEqual(constants.%U, constants.%T.d94) [symbolic = %specific_impl_fn.loc7_5.2 (constants.%specific_impl_fn.81f)] // CHECK:STDOUT: %bound_method.loc7_5.2: = bound_method %x.ref.loc7, %specific_impl_fn.loc7_5.1 diff --git a/toolchain/check/testdata/operators/overloaded/eq.carbon b/toolchain/check/testdata/operators/overloaded/eq.carbon index aed45ca20039..dff9733ed162 100644 --- a/toolchain/check/testdata/operators/overloaded/eq.carbon +++ b/toolchain/check/testdata/operators/overloaded/eq.carbon @@ -3,8 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon -// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only". -// EXTRA-ARGS: --dump-sem-ir-ranges=if-present // // AUTOUPDATE // TIP: To test this file alone, run: @@ -31,6 +29,24 @@ fn TestNotEqual(a: C, b: C) -> bool { return a != b; } +// --- eq_and_default.carbon + +package EqAndDefault; + +class C2 {}; + +impl C2 as Core.Eq { + fn Equal(self: C2, other: C2) -> bool; +} + +fn TestEqual(a: C2, b: C2) -> bool { + return a == b; +} + +fn TestNotEqual(a: C2, b: C2) -> bool { + return a != b; +} + // --- fail_no_impl.carbon package FailNoImpl; @@ -80,492 +96,3 @@ fn TestLhsBad(a: D, b: C) -> bool { // CHECK:STDERR: return a != b; } - -// CHECK:STDOUT: --- user.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %C: type = class_type @C [concrete] -// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %EqWith.type.f77: type = generic_interface_type @EqWith [concrete] -// CHECK:STDOUT: %EqWith.generic: %EqWith.type.f77 = struct_value () [concrete] -// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete] -// CHECK:STDOUT: %.f34: Core.Form = init_form bool [concrete] -// CHECK:STDOUT: %EqWith.type.d1f: type = facet_type <@EqWith, @EqWith(%C)> [concrete] -// CHECK:STDOUT: %.53e: = impl_self_witness %C, @EqWith, @EqWith(%C) [concrete] -// CHECK:STDOUT: %EqWith.impl_witness: = impl_witness @C.as.EqWith.impl.%EqWith.impl_witness_table [concrete] -// CHECK:STDOUT: %pattern_type.4a7: type = pattern_type %C [concrete] -// CHECK:STDOUT: %self.param_patt.c03: %pattern_type.4a7 = value_param_pattern [concrete] -// CHECK:STDOUT: %self.patt.363: %pattern_type.4a7 = wrapper_binding_pattern self, %self.param_patt.c03 [concrete] -// CHECK:STDOUT: %other.param_patt.b8c: %pattern_type.4a7 = value_param_pattern [concrete] -// CHECK:STDOUT: %other.patt.079: %pattern_type.4a7 = wrapper_binding_pattern other, %other.param_patt.b8c [concrete] -// CHECK:STDOUT: %return.patt.c0c: %pattern_type.831 = return_slot_pattern %return.param_patt, bool [concrete] -// CHECK:STDOUT: %C.as.EqWith.impl.Equal.type: type = fn_type @C.as.EqWith.impl.Equal [concrete] -// CHECK:STDOUT: %C.as.EqWith.impl.Equal: %C.as.EqWith.impl.Equal.type = struct_value () [concrete] -// CHECK:STDOUT: %C.as.EqWith.impl.NotEqual.type: type = fn_type @C.as.EqWith.impl.NotEqual [concrete] -// CHECK:STDOUT: %C.as.EqWith.impl.NotEqual: %C.as.EqWith.impl.NotEqual.type = struct_value () [concrete] -// CHECK:STDOUT: %EqWith.facet: %EqWith.type.d1f = facet_value %C, (%EqWith.impl_witness) [concrete] -// CHECK:STDOUT: %EqWith.WithSelf.Equal.type.e3d: type = fn_type @EqWith.WithSelf.Equal, @EqWith.WithSelf(%C, %EqWith.facet) [concrete] -// CHECK:STDOUT: %EqWith.WithSelf.NotEqual.type.23b: type = fn_type @EqWith.WithSelf.NotEqual, @EqWith.WithSelf(%C, %EqWith.facet) [concrete] -// CHECK:STDOUT: %a.param_patt: %pattern_type.4a7 = value_param_pattern [concrete] -// CHECK:STDOUT: %a.patt: %pattern_type.4a7 = wrapper_binding_pattern a, %a.param_patt [concrete] -// CHECK:STDOUT: %b.param_patt: %pattern_type.4a7 = value_param_pattern [concrete] -// CHECK:STDOUT: %b.patt: %pattern_type.4a7 = wrapper_binding_pattern b, %b.param_patt [concrete] -// CHECK:STDOUT: %TestEqual.type: type = fn_type @TestEqual [concrete] -// CHECK:STDOUT: %TestEqual: %TestEqual.type = struct_value () [concrete] -// CHECK:STDOUT: %.d78: type = fn_type_with_self_type %EqWith.WithSelf.Equal.type.e3d, %EqWith.facet [concrete] -// CHECK:STDOUT: %TestNotEqual.type: type = fn_type @TestNotEqual [concrete] -// CHECK:STDOUT: %TestNotEqual: %TestNotEqual.type = struct_value () [concrete] -// CHECK:STDOUT: %.701: type = fn_type_with_self_type %EqWith.WithSelf.NotEqual.type.23b, %EqWith.facet [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: .EqWith = %Core.EqWith -// CHECK:STDOUT: .Bool = %Core.Bool -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.EqWith: %EqWith.type.f77 = import_ref Core//prelude/operators/comparison, EqWith, loaded [concrete = constants.%EqWith.generic] -// CHECK:STDOUT: %Core.Bool: type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = bool] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .TestEqual = %TestEqual.decl -// CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} -// CHECK:STDOUT: impl_decl @C.as.EqWith.impl [concrete] {} { -// CHECK:STDOUT: %C.ref.loc6_6: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] -// CHECK:STDOUT: %EqWith.ref: %EqWith.type.f77 = name_ref EqWith, imports.%Core.EqWith [concrete = constants.%EqWith.generic] -// CHECK:STDOUT: %C.ref.loc6_23: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %EqWith.type: type = facet_type <@EqWith, @EqWith(constants.%C)> [concrete = constants.%EqWith.type.d1f] -// CHECK:STDOUT: } -// CHECK:STDOUT: %.loc6: = impl_self_witness @C.as.EqWith.impl.%C.ref.loc6_6, @EqWith, @EqWith(constants.%C) [concrete = constants.%.53e] -// CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [concrete = constants.%TestEqual] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.4a7 = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.4a7 = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc11_29.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc11_29.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc11_29.2: Core.Form = init_form %.loc11_29.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc11_17: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %a: %C = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc11_23: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %b: %C = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestNotEqual.decl: %TestNotEqual.type = fn_decl @TestNotEqual [concrete = constants.%TestNotEqual] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.4a7 = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.4a7 = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc15_32.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc15_32.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc15_32.2: Core.Form = init_form %.loc15_32.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc15_20: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %a: %C = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc15_26: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %b: %C = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: impl @C.as.EqWith.impl: %C.ref.loc6_6 as %EqWith.type { -// CHECK:STDOUT: %C.as.EqWith.impl.Equal.decl: %C.as.EqWith.impl.Equal.type = fn_decl @C.as.EqWith.impl.Equal [concrete = constants.%C.as.EqWith.impl.Equal] { -// CHECK:STDOUT: %self.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%self.param_patt.c03] -// CHECK:STDOUT: %self.patt: %pattern_type.4a7 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.363] -// CHECK:STDOUT: %other.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%other.param_patt.b8c] -// CHECK:STDOUT: %other.patt: %pattern_type.4a7 = wrapper_binding_pattern other, %other.param_patt [concrete = constants.%other.patt.079] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc7_34.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc7_34.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc7_34.2: Core.Form = init_form %.loc7_34.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %self.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc7_18: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %self: %C = wrapper_binding self, %self.param -// CHECK:STDOUT: %other.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc7_28: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %other: %C = wrapper_binding other, %other.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %C.as.EqWith.impl.NotEqual.decl: %C.as.EqWith.impl.NotEqual.type = fn_decl @C.as.EqWith.impl.NotEqual [concrete = constants.%C.as.EqWith.impl.NotEqual] { -// CHECK:STDOUT: %self.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%self.param_patt.c03] -// CHECK:STDOUT: %self.patt: %pattern_type.4a7 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.363] -// CHECK:STDOUT: %other.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%other.param_patt.b8c] -// CHECK:STDOUT: %other.patt: %pattern_type.4a7 = wrapper_binding_pattern other, %other.param_patt [concrete = constants.%other.patt.079] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc8_37.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc8_37.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc8_37.2: Core.Form = init_form %.loc8_37.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %self.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc8_21: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %self: %C = wrapper_binding self, %self.param -// CHECK:STDOUT: %other.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc8_31: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %other: %C = wrapper_binding other, %other.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %EqWith.impl_witness_table = impl_witness_table (%C.as.EqWith.impl.Equal.decl, %C.as.EqWith.impl.NotEqual.decl), @C.as.EqWith.impl [concrete] -// CHECK:STDOUT: %EqWith.impl_witness: = impl_witness %EqWith.impl_witness_table [concrete = constants.%EqWith.impl_witness] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .C = -// CHECK:STDOUT: .Equal = %C.as.EqWith.impl.Equal.decl -// CHECK:STDOUT: .NotEqual = %C.as.EqWith.impl.NotEqual.decl -// CHECK:STDOUT: extend %EqWith.type -// CHECK:STDOUT: witness = %EqWith.impl_witness -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.EqWith.impl.Equal(%self.param: %C, %other.param: %C) -> out %return.param: bool; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.EqWith.impl.NotEqual(%self.param: %C, %other.param: %C) -> out %return.param: bool; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestEqual(%a.param: %C, %b.param: %C) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %b.ref: %C = name_ref b, %b -// CHECK:STDOUT: %impl.elem0: %.d78 = impl_witness_access constants.%EqWith.impl_witness, element0 [concrete = constants.%C.as.EqWith.impl.Equal] -// CHECK:STDOUT: %bound_method: = bound_method %a.ref, %impl.elem0 -// CHECK:STDOUT: %C.as.EqWith.impl.Equal.call: init bool = call %bound_method(%a.ref, %b.ref) -// CHECK:STDOUT: return %C.as.EqWith.impl.Equal.call -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestNotEqual(%a.param: %C, %b.param: %C) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %b.ref: %C = name_ref b, %b -// CHECK:STDOUT: %impl.elem1: %.701 = impl_witness_access constants.%EqWith.impl_witness, element1 [concrete = constants.%C.as.EqWith.impl.NotEqual] -// CHECK:STDOUT: %bound_method: = bound_method %a.ref, %impl.elem1 -// CHECK:STDOUT: %C.as.EqWith.impl.NotEqual.call: init bool = call %bound_method(%a.ref, %b.ref) -// CHECK:STDOUT: return %C.as.EqWith.impl.NotEqual.call -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- fail_no_impl.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %D: type = class_type @D [concrete] -// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %pattern_type.9dc: type = pattern_type %D [concrete] -// CHECK:STDOUT: %a.param_patt: %pattern_type.9dc = value_param_pattern [concrete] -// CHECK:STDOUT: %a.patt: %pattern_type.9dc = wrapper_binding_pattern a, %a.param_patt [concrete] -// CHECK:STDOUT: %b.param_patt: %pattern_type.9dc = value_param_pattern [concrete] -// CHECK:STDOUT: %b.patt: %pattern_type.9dc = wrapper_binding_pattern b, %b.param_patt [concrete] -// CHECK:STDOUT: %.f34: Core.Form = init_form bool [concrete] -// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete] -// CHECK:STDOUT: %return.patt.c0c: %pattern_type.831 = return_slot_pattern %return.param_patt, bool [concrete] -// CHECK:STDOUT: %TestEqual.type: type = fn_type @TestEqual [concrete] -// CHECK:STDOUT: %TestEqual: %TestEqual.type = struct_value () [concrete] -// CHECK:STDOUT: %EqWith.type.f77: type = generic_interface_type @EqWith [concrete] -// CHECK:STDOUT: %EqWith.generic: %EqWith.type.f77 = struct_value () [concrete] -// CHECK:STDOUT: %TestNotEqual.type: type = fn_type @TestNotEqual [concrete] -// CHECK:STDOUT: %TestNotEqual: %TestNotEqual.type = struct_value () [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: .Bool = %Core.Bool -// CHECK:STDOUT: .EqWith = %Core.EqWith -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.Bool: type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = bool] -// CHECK:STDOUT: %Core.EqWith: %EqWith.type.f77 = import_ref Core//prelude/operators/comparison, EqWith, loaded [concrete = constants.%EqWith.generic] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .D = %D.decl -// CHECK:STDOUT: .TestEqual = %TestEqual.decl -// CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {} -// CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [concrete = constants.%TestEqual] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.9dc = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.9dc = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc6_29.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc6_29.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc6_29.2: Core.Form = init_form %.loc6_29.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %D = value_param call_param0 -// CHECK:STDOUT: %D.ref.loc6_17: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %a: %D = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %D = value_param call_param1 -// CHECK:STDOUT: %D.ref.loc6_23: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %b: %D = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestNotEqual.decl: %TestNotEqual.type = fn_decl @TestNotEqual [concrete = constants.%TestNotEqual] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.9dc = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.9dc = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc14_32.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc14_32.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc14_32.2: Core.Form = init_form %.loc14_32.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %D = value_param call_param0 -// CHECK:STDOUT: %D.ref.loc14_20: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %a: %D = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %D = value_param call_param1 -// CHECK:STDOUT: %D.ref.loc14_26: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %b: %D = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @D { -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%D -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestEqual(%a.param: %D, %b.param: %D) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %D = name_ref a, %a -// CHECK:STDOUT: %b.ref: %D = name_ref b, %b -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestNotEqual(%a.param: %D, %b.param: %D) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %D = name_ref a, %a -// CHECK:STDOUT: %b.ref: %D = name_ref b, %b -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- fail_no_impl_for_args.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %C: type = class_type @C [concrete] -// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %D: type = class_type @D [concrete] -// CHECK:STDOUT: %EqWith.type.f77: type = generic_interface_type @EqWith [concrete] -// CHECK:STDOUT: %EqWith.generic: %EqWith.type.f77 = struct_value () [concrete] -// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete] -// CHECK:STDOUT: %.f34: Core.Form = init_form bool [concrete] -// CHECK:STDOUT: %EqWith.type.c2a: type = facet_type <@EqWith, @EqWith(%C)> [concrete] -// CHECK:STDOUT: %.786: = impl_self_witness %C, @EqWith, @EqWith(%C) [concrete] -// CHECK:STDOUT: %EqWith.impl_witness: = impl_witness @C.as.EqWith.impl.%EqWith.impl_witness_table [concrete] -// CHECK:STDOUT: %pattern_type.eae: type = pattern_type %C [concrete] -// CHECK:STDOUT: %self.param_patt.bcb: %pattern_type.eae = value_param_pattern [concrete] -// CHECK:STDOUT: %self.patt.594: %pattern_type.eae = wrapper_binding_pattern self, %self.param_patt.bcb [concrete] -// CHECK:STDOUT: %other.param_patt.d05: %pattern_type.eae = value_param_pattern [concrete] -// CHECK:STDOUT: %other.patt.da2: %pattern_type.eae = wrapper_binding_pattern other, %other.param_patt.d05 [concrete] -// CHECK:STDOUT: %return.patt.c0c: %pattern_type.831 = return_slot_pattern %return.param_patt, bool [concrete] -// CHECK:STDOUT: %C.as.EqWith.impl.Equal.type: type = fn_type @C.as.EqWith.impl.Equal [concrete] -// CHECK:STDOUT: %C.as.EqWith.impl.Equal: %C.as.EqWith.impl.Equal.type = struct_value () [concrete] -// CHECK:STDOUT: %C.as.EqWith.impl.NotEqual.type: type = fn_type @C.as.EqWith.impl.NotEqual [concrete] -// CHECK:STDOUT: %C.as.EqWith.impl.NotEqual: %C.as.EqWith.impl.NotEqual.type = struct_value () [concrete] -// CHECK:STDOUT: %a.param_patt.70a: %pattern_type.eae = value_param_pattern [concrete] -// CHECK:STDOUT: %a.patt.f7b: %pattern_type.eae = wrapper_binding_pattern a, %a.param_patt.70a [concrete] -// CHECK:STDOUT: %pattern_type.d59: type = pattern_type %D [concrete] -// CHECK:STDOUT: %b.param_patt.758: %pattern_type.d59 = value_param_pattern [concrete] -// CHECK:STDOUT: %b.patt.3bf: %pattern_type.d59 = wrapper_binding_pattern b, %b.param_patt.758 [concrete] -// CHECK:STDOUT: %TestRhsBad.type: type = fn_type @TestRhsBad [concrete] -// CHECK:STDOUT: %TestRhsBad: %TestRhsBad.type = struct_value () [concrete] -// CHECK:STDOUT: %a.param_patt.66d: %pattern_type.d59 = value_param_pattern [concrete] -// CHECK:STDOUT: %a.patt.9ba: %pattern_type.d59 = wrapper_binding_pattern a, %a.param_patt.66d [concrete] -// CHECK:STDOUT: %b.param_patt.16c: %pattern_type.eae = value_param_pattern [concrete] -// CHECK:STDOUT: %b.patt.518: %pattern_type.eae = wrapper_binding_pattern b, %b.param_patt.16c [concrete] -// CHECK:STDOUT: %TestLhsBad.type: type = fn_type @TestLhsBad [concrete] -// CHECK:STDOUT: %TestLhsBad: %TestLhsBad.type = struct_value () [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: .EqWith = %Core.EqWith -// CHECK:STDOUT: .Bool = %Core.Bool -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.EqWith: %EqWith.type.f77 = import_ref Core//prelude/operators/comparison, EqWith, loaded [concrete = constants.%EqWith.generic] -// CHECK:STDOUT: %Core.Bool: type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = bool] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .D = %D.decl -// CHECK:STDOUT: .TestRhsBad = %TestRhsBad.decl -// CHECK:STDOUT: .TestLhsBad = %TestLhsBad.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} -// CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {} -// CHECK:STDOUT: impl_decl @C.as.EqWith.impl [concrete] {} { -// CHECK:STDOUT: %C.ref.loc7_6: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] -// CHECK:STDOUT: %EqWith.ref: %EqWith.type.f77 = name_ref EqWith, imports.%Core.EqWith [concrete = constants.%EqWith.generic] -// CHECK:STDOUT: %C.ref.loc7_23: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %EqWith.type: type = facet_type <@EqWith, @EqWith(constants.%C)> [concrete = constants.%EqWith.type.c2a] -// CHECK:STDOUT: } -// CHECK:STDOUT: %.loc7: = impl_self_witness @C.as.EqWith.impl.%C.ref.loc7_6, @EqWith, @EqWith(constants.%C) [concrete = constants.%.786] -// CHECK:STDOUT: %TestRhsBad.decl: %TestRhsBad.type = fn_decl @TestRhsBad [concrete = constants.%TestRhsBad] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.eae = value_param_pattern [concrete = constants.%a.param_patt.70a] -// CHECK:STDOUT: %a.patt: %pattern_type.eae = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt.f7b] -// CHECK:STDOUT: %b.param_patt: %pattern_type.d59 = value_param_pattern [concrete = constants.%b.param_patt.758] -// CHECK:STDOUT: %b.patt: %pattern_type.d59 = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt.3bf] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc12_30.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc12_30.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc12_30.2: Core.Form = init_form %.loc12_30.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %a: %C = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %D = value_param call_param1 -// CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %b: %D = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestLhsBad.decl: %TestLhsBad.type = fn_decl @TestLhsBad [concrete = constants.%TestLhsBad] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.d59 = value_param_pattern [concrete = constants.%a.param_patt.66d] -// CHECK:STDOUT: %a.patt: %pattern_type.d59 = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt.9ba] -// CHECK:STDOUT: %b.param_patt: %pattern_type.eae = value_param_pattern [concrete = constants.%b.param_patt.16c] -// CHECK:STDOUT: %b.patt: %pattern_type.eae = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt.518] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc20_30.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc20_30.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc20_30.2: Core.Form = init_form %.loc20_30.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %D = value_param call_param0 -// CHECK:STDOUT: %D.ref: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %a: %D = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %b: %C = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: impl @C.as.EqWith.impl: %C.ref.loc7_6 as %EqWith.type { -// CHECK:STDOUT: %C.as.EqWith.impl.Equal.decl: %C.as.EqWith.impl.Equal.type = fn_decl @C.as.EqWith.impl.Equal [concrete = constants.%C.as.EqWith.impl.Equal] { -// CHECK:STDOUT: %self.param_patt: %pattern_type.eae = value_param_pattern [concrete = constants.%self.param_patt.bcb] -// CHECK:STDOUT: %self.patt: %pattern_type.eae = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.594] -// CHECK:STDOUT: %other.param_patt: %pattern_type.eae = value_param_pattern [concrete = constants.%other.param_patt.d05] -// CHECK:STDOUT: %other.patt: %pattern_type.eae = wrapper_binding_pattern other, %other.param_patt [concrete = constants.%other.patt.da2] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc8_34.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc8_34.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc8_34.2: Core.Form = init_form %.loc8_34.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %self.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc8_18: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %self: %C = wrapper_binding self, %self.param -// CHECK:STDOUT: %other.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc8_28: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %other: %C = wrapper_binding other, %other.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %C.as.EqWith.impl.NotEqual.decl: %C.as.EqWith.impl.NotEqual.type = fn_decl @C.as.EqWith.impl.NotEqual [concrete = constants.%C.as.EqWith.impl.NotEqual] { -// CHECK:STDOUT: %self.param_patt: %pattern_type.eae = value_param_pattern [concrete = constants.%self.param_patt.bcb] -// CHECK:STDOUT: %self.patt: %pattern_type.eae = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.594] -// CHECK:STDOUT: %other.param_patt: %pattern_type.eae = value_param_pattern [concrete = constants.%other.param_patt.d05] -// CHECK:STDOUT: %other.patt: %pattern_type.eae = wrapper_binding_pattern other, %other.param_patt [concrete = constants.%other.patt.da2] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc9_37.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc9_37.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc9_37.2: Core.Form = init_form %.loc9_37.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %self.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc9_21: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %self: %C = wrapper_binding self, %self.param -// CHECK:STDOUT: %other.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc9_31: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %other: %C = wrapper_binding other, %other.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %EqWith.impl_witness_table = impl_witness_table (%C.as.EqWith.impl.Equal.decl, %C.as.EqWith.impl.NotEqual.decl), @C.as.EqWith.impl [concrete] -// CHECK:STDOUT: %EqWith.impl_witness: = impl_witness %EqWith.impl_witness_table [concrete = constants.%EqWith.impl_witness] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .C = -// CHECK:STDOUT: .Equal = %C.as.EqWith.impl.Equal.decl -// CHECK:STDOUT: .NotEqual = %C.as.EqWith.impl.NotEqual.decl -// CHECK:STDOUT: extend %EqWith.type -// CHECK:STDOUT: witness = %EqWith.impl_witness -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @D { -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%D -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.EqWith.impl.Equal(%self.param: %C, %other.param: %C) -> out %return.param: bool; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.EqWith.impl.NotEqual(%self.param: %C, %other.param: %C) -> out %return.param: bool; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestRhsBad(%a.param: %C, %b.param: %D) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %b.ref: %D = name_ref b, %b -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestLhsBad(%a.param: %D, %b.param: %C) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %D = name_ref a, %a -// CHECK:STDOUT: %b.ref: %C = name_ref b, %b -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/check/testdata/operators/overloaded/ordered.carbon b/toolchain/check/testdata/operators/overloaded/ordered.carbon index 3c9c4ab7bce5..169f55ccab9c 100644 --- a/toolchain/check/testdata/operators/overloaded/ordered.carbon +++ b/toolchain/check/testdata/operators/overloaded/ordered.carbon @@ -3,8 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/full.carbon -// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only". -// EXTRA-ARGS: --dump-sem-ir-ranges=if-present // // AUTOUPDATE // TIP: To test this file alone, run: @@ -41,6 +39,35 @@ fn TestGreaterEqual(a: C, b: C) -> bool { return a >= b; } +// --- ordered.carbon + +package Ordered; + +class C2 {}; + +impl C2 as Core.Ordered { + fn Less(self: C2, other: C2) -> bool; + fn LessOrEquivalent(self: C2, other: C2) -> bool; + fn Greater(self: C2, other: C2) -> bool; + fn GreaterOrEquivalent(self: C2, other: C2) -> bool; +} + +fn TestLess(a: C2, b: C2) -> bool { + return a < b; +} + +fn TestLessEqual(a: C2, b: C2) -> bool { + return a <= b; +} + +fn TestGreater(a: C2, b: C2) -> bool { + return a > b; +} + +fn TestGreaterEqual(a: C2, b: C2) -> bool { + return a >= b; +} + // --- fail_no_impl.carbon package FailNoImpl; @@ -78,472 +105,3 @@ fn TestGreaterEqual(a: D, b: D) -> bool { // CHECK:STDERR: return a >= b; } - -// CHECK:STDOUT: --- user.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %C: type = class_type @C [concrete] -// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %OrderedWith.type.ad8: type = generic_interface_type @OrderedWith [concrete] -// CHECK:STDOUT: %OrderedWith.generic: %OrderedWith.type.ad8 = struct_value () [concrete] -// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete] -// CHECK:STDOUT: %.f34: Core.Form = init_form bool [concrete] -// CHECK:STDOUT: %OrderedWith.type.108: type = facet_type <@OrderedWith, @OrderedWith(%C)> [concrete] -// CHECK:STDOUT: %.71b: = impl_self_witness %C, @OrderedWith, @OrderedWith(%C) [concrete] -// CHECK:STDOUT: %OrderedWith.impl_witness: = impl_witness @C.as.OrderedWith.impl.%OrderedWith.impl_witness_table [concrete] -// CHECK:STDOUT: %pattern_type.4a7: type = pattern_type %C [concrete] -// CHECK:STDOUT: %self.param_patt.c03: %pattern_type.4a7 = value_param_pattern [concrete] -// CHECK:STDOUT: %self.patt.363: %pattern_type.4a7 = wrapper_binding_pattern self, %self.param_patt.c03 [concrete] -// CHECK:STDOUT: %other.param_patt.b8c: %pattern_type.4a7 = value_param_pattern [concrete] -// CHECK:STDOUT: %other.patt.079: %pattern_type.4a7 = wrapper_binding_pattern other, %other.param_patt.b8c [concrete] -// CHECK:STDOUT: %return.patt.c0c: %pattern_type.831 = return_slot_pattern %return.param_patt, bool [concrete] -// CHECK:STDOUT: %C.as.OrderedWith.impl.Less.type: type = fn_type @C.as.OrderedWith.impl.Less [concrete] -// CHECK:STDOUT: %C.as.OrderedWith.impl.Less: %C.as.OrderedWith.impl.Less.type = struct_value () [concrete] -// CHECK:STDOUT: %C.as.OrderedWith.impl.LessOrEquivalent.type: type = fn_type @C.as.OrderedWith.impl.LessOrEquivalent [concrete] -// CHECK:STDOUT: %C.as.OrderedWith.impl.LessOrEquivalent: %C.as.OrderedWith.impl.LessOrEquivalent.type = struct_value () [concrete] -// CHECK:STDOUT: %C.as.OrderedWith.impl.Greater.type: type = fn_type @C.as.OrderedWith.impl.Greater [concrete] -// CHECK:STDOUT: %C.as.OrderedWith.impl.Greater: %C.as.OrderedWith.impl.Greater.type = struct_value () [concrete] -// CHECK:STDOUT: %C.as.OrderedWith.impl.GreaterOrEquivalent.type: type = fn_type @C.as.OrderedWith.impl.GreaterOrEquivalent [concrete] -// CHECK:STDOUT: %C.as.OrderedWith.impl.GreaterOrEquivalent: %C.as.OrderedWith.impl.GreaterOrEquivalent.type = struct_value () [concrete] -// CHECK:STDOUT: %OrderedWith.facet: %OrderedWith.type.108 = facet_value %C, (%OrderedWith.impl_witness) [concrete] -// CHECK:STDOUT: %OrderedWith.WithSelf.Less.type.312: type = fn_type @OrderedWith.WithSelf.Less, @OrderedWith.WithSelf(%C, %OrderedWith.facet) [concrete] -// CHECK:STDOUT: %OrderedWith.WithSelf.LessOrEquivalent.type.ef9: type = fn_type @OrderedWith.WithSelf.LessOrEquivalent, @OrderedWith.WithSelf(%C, %OrderedWith.facet) [concrete] -// CHECK:STDOUT: %OrderedWith.WithSelf.Greater.type.f85: type = fn_type @OrderedWith.WithSelf.Greater, @OrderedWith.WithSelf(%C, %OrderedWith.facet) [concrete] -// CHECK:STDOUT: %OrderedWith.WithSelf.GreaterOrEquivalent.type.ae3: type = fn_type @OrderedWith.WithSelf.GreaterOrEquivalent, @OrderedWith.WithSelf(%C, %OrderedWith.facet) [concrete] -// CHECK:STDOUT: %a.param_patt: %pattern_type.4a7 = value_param_pattern [concrete] -// CHECK:STDOUT: %a.patt: %pattern_type.4a7 = wrapper_binding_pattern a, %a.param_patt [concrete] -// CHECK:STDOUT: %b.param_patt: %pattern_type.4a7 = value_param_pattern [concrete] -// CHECK:STDOUT: %b.patt: %pattern_type.4a7 = wrapper_binding_pattern b, %b.param_patt [concrete] -// CHECK:STDOUT: %TestLess.type: type = fn_type @TestLess [concrete] -// CHECK:STDOUT: %TestLess: %TestLess.type = struct_value () [concrete] -// CHECK:STDOUT: %.b78: type = fn_type_with_self_type %OrderedWith.WithSelf.Less.type.312, %OrderedWith.facet [concrete] -// CHECK:STDOUT: %TestLessEqual.type: type = fn_type @TestLessEqual [concrete] -// CHECK:STDOUT: %TestLessEqual: %TestLessEqual.type = struct_value () [concrete] -// CHECK:STDOUT: %.f61: type = fn_type_with_self_type %OrderedWith.WithSelf.LessOrEquivalent.type.ef9, %OrderedWith.facet [concrete] -// CHECK:STDOUT: %TestGreater.type: type = fn_type @TestGreater [concrete] -// CHECK:STDOUT: %TestGreater: %TestGreater.type = struct_value () [concrete] -// CHECK:STDOUT: %.295: type = fn_type_with_self_type %OrderedWith.WithSelf.Greater.type.f85, %OrderedWith.facet [concrete] -// CHECK:STDOUT: %TestGreaterEqual.type: type = fn_type @TestGreaterEqual [concrete] -// CHECK:STDOUT: %TestGreaterEqual: %TestGreaterEqual.type = struct_value () [concrete] -// CHECK:STDOUT: %.d60: type = fn_type_with_self_type %OrderedWith.WithSelf.GreaterOrEquivalent.type.ae3, %OrderedWith.facet [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: .OrderedWith = %Core.OrderedWith -// CHECK:STDOUT: .Bool = %Core.Bool -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.OrderedWith: %OrderedWith.type.ad8 = import_ref Core//prelude/operators/comparison, OrderedWith, loaded [concrete = constants.%OrderedWith.generic] -// CHECK:STDOUT: %Core.Bool: type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = bool] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .C = %C.decl -// CHECK:STDOUT: .TestLess = %TestLess.decl -// CHECK:STDOUT: .TestLessEqual = %TestLessEqual.decl -// CHECK:STDOUT: .TestGreater = %TestGreater.decl -// CHECK:STDOUT: .TestGreaterEqual = %TestGreaterEqual.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} -// CHECK:STDOUT: impl_decl @C.as.OrderedWith.impl [concrete] {} { -// CHECK:STDOUT: %C.ref.loc6_6: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] -// CHECK:STDOUT: %OrderedWith.ref: %OrderedWith.type.ad8 = name_ref OrderedWith, imports.%Core.OrderedWith [concrete = constants.%OrderedWith.generic] -// CHECK:STDOUT: %C.ref.loc6_28: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %OrderedWith.type: type = facet_type <@OrderedWith, @OrderedWith(constants.%C)> [concrete = constants.%OrderedWith.type.108] -// CHECK:STDOUT: } -// CHECK:STDOUT: %.loc6: = impl_self_witness @C.as.OrderedWith.impl.%C.ref.loc6_6, @OrderedWith, @OrderedWith(constants.%C) [concrete = constants.%.71b] -// CHECK:STDOUT: %TestLess.decl: %TestLess.type = fn_decl @TestLess [concrete = constants.%TestLess] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.4a7 = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.4a7 = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc13_28.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc13_28.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc13_28.2: Core.Form = init_form %.loc13_28.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc13_16: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %a: %C = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc13_22: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %b: %C = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestLessEqual.decl: %TestLessEqual.type = fn_decl @TestLessEqual [concrete = constants.%TestLessEqual] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.4a7 = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.4a7 = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc17_33.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc17_33.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc17_33.2: Core.Form = init_form %.loc17_33.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc17_21: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %a: %C = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc17_27: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %b: %C = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestGreater.decl: %TestGreater.type = fn_decl @TestGreater [concrete = constants.%TestGreater] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.4a7 = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.4a7 = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc21_31.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc21_31.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc21_31.2: Core.Form = init_form %.loc21_31.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc21_19: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %a: %C = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc21_25: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %b: %C = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestGreaterEqual.decl: %TestGreaterEqual.type = fn_decl @TestGreaterEqual [concrete = constants.%TestGreaterEqual] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.4a7 = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.4a7 = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc25_36.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc25_36.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc25_36.2: Core.Form = init_form %.loc25_36.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc25_24: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %a: %C = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc25_30: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %b: %C = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: impl @C.as.OrderedWith.impl: %C.ref.loc6_6 as %OrderedWith.type { -// CHECK:STDOUT: %C.as.OrderedWith.impl.Less.decl: %C.as.OrderedWith.impl.Less.type = fn_decl @C.as.OrderedWith.impl.Less [concrete = constants.%C.as.OrderedWith.impl.Less] { -// CHECK:STDOUT: %self.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%self.param_patt.c03] -// CHECK:STDOUT: %self.patt: %pattern_type.4a7 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.363] -// CHECK:STDOUT: %other.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%other.param_patt.b8c] -// CHECK:STDOUT: %other.patt: %pattern_type.4a7 = wrapper_binding_pattern other, %other.param_patt [concrete = constants.%other.patt.079] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc7_33.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc7_33.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc7_33.2: Core.Form = init_form %.loc7_33.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %self.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc7_17: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %self: %C = wrapper_binding self, %self.param -// CHECK:STDOUT: %other.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc7_27: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %other: %C = wrapper_binding other, %other.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %C.as.OrderedWith.impl.LessOrEquivalent.decl: %C.as.OrderedWith.impl.LessOrEquivalent.type = fn_decl @C.as.OrderedWith.impl.LessOrEquivalent [concrete = constants.%C.as.OrderedWith.impl.LessOrEquivalent] { -// CHECK:STDOUT: %self.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%self.param_patt.c03] -// CHECK:STDOUT: %self.patt: %pattern_type.4a7 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.363] -// CHECK:STDOUT: %other.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%other.param_patt.b8c] -// CHECK:STDOUT: %other.patt: %pattern_type.4a7 = wrapper_binding_pattern other, %other.param_patt [concrete = constants.%other.patt.079] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc8_45.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc8_45.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc8_45.2: Core.Form = init_form %.loc8_45.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %self.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc8_29: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %self: %C = wrapper_binding self, %self.param -// CHECK:STDOUT: %other.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc8_39: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %other: %C = wrapper_binding other, %other.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %C.as.OrderedWith.impl.Greater.decl: %C.as.OrderedWith.impl.Greater.type = fn_decl @C.as.OrderedWith.impl.Greater [concrete = constants.%C.as.OrderedWith.impl.Greater] { -// CHECK:STDOUT: %self.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%self.param_patt.c03] -// CHECK:STDOUT: %self.patt: %pattern_type.4a7 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.363] -// CHECK:STDOUT: %other.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%other.param_patt.b8c] -// CHECK:STDOUT: %other.patt: %pattern_type.4a7 = wrapper_binding_pattern other, %other.param_patt [concrete = constants.%other.patt.079] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc9_36.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc9_36.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc9_36.2: Core.Form = init_form %.loc9_36.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %self.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc9_20: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %self: %C = wrapper_binding self, %self.param -// CHECK:STDOUT: %other.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc9_30: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %other: %C = wrapper_binding other, %other.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %C.as.OrderedWith.impl.GreaterOrEquivalent.decl: %C.as.OrderedWith.impl.GreaterOrEquivalent.type = fn_decl @C.as.OrderedWith.impl.GreaterOrEquivalent [concrete = constants.%C.as.OrderedWith.impl.GreaterOrEquivalent] { -// CHECK:STDOUT: %self.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%self.param_patt.c03] -// CHECK:STDOUT: %self.patt: %pattern_type.4a7 = wrapper_binding_pattern self, %self.param_patt [concrete = constants.%self.patt.363] -// CHECK:STDOUT: %other.param_patt: %pattern_type.4a7 = value_param_pattern [concrete = constants.%other.param_patt.b8c] -// CHECK:STDOUT: %other.patt: %pattern_type.4a7 = wrapper_binding_pattern other, %other.param_patt [concrete = constants.%other.patt.079] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc10_48.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc10_48.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc10_48.2: Core.Form = init_form %.loc10_48.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %self.param: %C = value_param call_param0 -// CHECK:STDOUT: %C.ref.loc10_32: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %self: %C = wrapper_binding self, %self.param -// CHECK:STDOUT: %other.param: %C = value_param call_param1 -// CHECK:STDOUT: %C.ref.loc10_42: type = name_ref C, file.%C.decl [concrete = constants.%C] -// CHECK:STDOUT: %other: %C = wrapper_binding other, %other.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %OrderedWith.impl_witness_table = impl_witness_table (%C.as.OrderedWith.impl.Less.decl, %C.as.OrderedWith.impl.LessOrEquivalent.decl, %C.as.OrderedWith.impl.Greater.decl, %C.as.OrderedWith.impl.GreaterOrEquivalent.decl), @C.as.OrderedWith.impl [concrete] -// CHECK:STDOUT: %OrderedWith.impl_witness: = impl_witness %OrderedWith.impl_witness_table [concrete = constants.%OrderedWith.impl_witness] -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .C = -// CHECK:STDOUT: .Less = %C.as.OrderedWith.impl.Less.decl -// CHECK:STDOUT: .LessOrEquivalent = %C.as.OrderedWith.impl.LessOrEquivalent.decl -// CHECK:STDOUT: .Greater = %C.as.OrderedWith.impl.Greater.decl -// CHECK:STDOUT: .GreaterOrEquivalent = %C.as.OrderedWith.impl.GreaterOrEquivalent.decl -// CHECK:STDOUT: extend %OrderedWith.type -// CHECK:STDOUT: witness = %OrderedWith.impl_witness -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @C { -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%C -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.OrderedWith.impl.Less(%self.param: %C, %other.param: %C) -> out %return.param: bool; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.OrderedWith.impl.LessOrEquivalent(%self.param: %C, %other.param: %C) -> out %return.param: bool; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.OrderedWith.impl.Greater(%self.param: %C, %other.param: %C) -> out %return.param: bool; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @C.as.OrderedWith.impl.GreaterOrEquivalent(%self.param: %C, %other.param: %C) -> out %return.param: bool; -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestLess(%a.param: %C, %b.param: %C) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %b.ref: %C = name_ref b, %b -// CHECK:STDOUT: %impl.elem0: %.b78 = impl_witness_access constants.%OrderedWith.impl_witness, element0 [concrete = constants.%C.as.OrderedWith.impl.Less] -// CHECK:STDOUT: %bound_method: = bound_method %a.ref, %impl.elem0 -// CHECK:STDOUT: %C.as.OrderedWith.impl.Less.call: init bool = call %bound_method(%a.ref, %b.ref) -// CHECK:STDOUT: return %C.as.OrderedWith.impl.Less.call -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestLessEqual(%a.param: %C, %b.param: %C) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %b.ref: %C = name_ref b, %b -// CHECK:STDOUT: %impl.elem1: %.f61 = impl_witness_access constants.%OrderedWith.impl_witness, element1 [concrete = constants.%C.as.OrderedWith.impl.LessOrEquivalent] -// CHECK:STDOUT: %bound_method: = bound_method %a.ref, %impl.elem1 -// CHECK:STDOUT: %C.as.OrderedWith.impl.LessOrEquivalent.call: init bool = call %bound_method(%a.ref, %b.ref) -// CHECK:STDOUT: return %C.as.OrderedWith.impl.LessOrEquivalent.call -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestGreater(%a.param: %C, %b.param: %C) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %b.ref: %C = name_ref b, %b -// CHECK:STDOUT: %impl.elem2: %.295 = impl_witness_access constants.%OrderedWith.impl_witness, element2 [concrete = constants.%C.as.OrderedWith.impl.Greater] -// CHECK:STDOUT: %bound_method: = bound_method %a.ref, %impl.elem2 -// CHECK:STDOUT: %C.as.OrderedWith.impl.Greater.call: init bool = call %bound_method(%a.ref, %b.ref) -// CHECK:STDOUT: return %C.as.OrderedWith.impl.Greater.call -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestGreaterEqual(%a.param: %C, %b.param: %C) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %C = name_ref a, %a -// CHECK:STDOUT: %b.ref: %C = name_ref b, %b -// CHECK:STDOUT: %impl.elem3: %.d60 = impl_witness_access constants.%OrderedWith.impl_witness, element3 [concrete = constants.%C.as.OrderedWith.impl.GreaterOrEquivalent] -// CHECK:STDOUT: %bound_method: = bound_method %a.ref, %impl.elem3 -// CHECK:STDOUT: %C.as.OrderedWith.impl.GreaterOrEquivalent.call: init bool = call %bound_method(%a.ref, %b.ref) -// CHECK:STDOUT: return %C.as.OrderedWith.impl.GreaterOrEquivalent.call -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: --- fail_no_impl.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %D: type = class_type @D [concrete] -// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] -// CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] -// CHECK:STDOUT: %pattern_type.9dc: type = pattern_type %D [concrete] -// CHECK:STDOUT: %a.param_patt: %pattern_type.9dc = value_param_pattern [concrete] -// CHECK:STDOUT: %a.patt: %pattern_type.9dc = wrapper_binding_pattern a, %a.param_patt [concrete] -// CHECK:STDOUT: %b.param_patt: %pattern_type.9dc = value_param_pattern [concrete] -// CHECK:STDOUT: %b.patt: %pattern_type.9dc = wrapper_binding_pattern b, %b.param_patt [concrete] -// CHECK:STDOUT: %.f34: Core.Form = init_form bool [concrete] -// CHECK:STDOUT: %pattern_type.831: type = pattern_type bool [concrete] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete] -// CHECK:STDOUT: %return.patt.c0c: %pattern_type.831 = return_slot_pattern %return.param_patt, bool [concrete] -// CHECK:STDOUT: %TestLess.type: type = fn_type @TestLess [concrete] -// CHECK:STDOUT: %TestLess: %TestLess.type = struct_value () [concrete] -// CHECK:STDOUT: %OrderedWith.type.ad8: type = generic_interface_type @OrderedWith [concrete] -// CHECK:STDOUT: %OrderedWith.generic: %OrderedWith.type.ad8 = struct_value () [concrete] -// CHECK:STDOUT: %TestLessEqual.type: type = fn_type @TestLessEqual [concrete] -// CHECK:STDOUT: %TestLessEqual: %TestLessEqual.type = struct_value () [concrete] -// CHECK:STDOUT: %TestGreater.type: type = fn_type @TestGreater [concrete] -// CHECK:STDOUT: %TestGreater: %TestGreater.type = struct_value () [concrete] -// CHECK:STDOUT: %TestGreaterEqual.type: type = fn_type @TestGreaterEqual [concrete] -// CHECK:STDOUT: %TestGreaterEqual: %TestGreaterEqual.type = struct_value () [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: imports { -// CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { -// CHECK:STDOUT: .Bool = %Core.Bool -// CHECK:STDOUT: .OrderedWith = %Core.OrderedWith -// CHECK:STDOUT: import Core//prelude -// CHECK:STDOUT: import Core//prelude/... -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.Bool: type = import_ref Core//prelude/types/bool, Bool, loaded [concrete = bool] -// CHECK:STDOUT: %Core.OrderedWith: %OrderedWith.type.ad8 = import_ref Core//prelude/operators/comparison, OrderedWith, loaded [concrete = constants.%OrderedWith.generic] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Core = imports.%Core -// CHECK:STDOUT: .D = %D.decl -// CHECK:STDOUT: .TestLess = %TestLess.decl -// CHECK:STDOUT: .TestLessEqual = %TestLessEqual.decl -// CHECK:STDOUT: .TestGreater = %TestGreater.decl -// CHECK:STDOUT: .TestGreaterEqual = %TestGreaterEqual.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Core.import = import Core -// CHECK:STDOUT: %D.decl: type = class_decl @D [concrete = constants.%D] {} {} -// CHECK:STDOUT: %TestLess.decl: %TestLess.type = fn_decl @TestLess [concrete = constants.%TestLess] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.9dc = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.9dc = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc6_28.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc6_28.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc6_28.2: Core.Form = init_form %.loc6_28.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %D = value_param call_param0 -// CHECK:STDOUT: %D.ref.loc6_16: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %a: %D = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %D = value_param call_param1 -// CHECK:STDOUT: %D.ref.loc6_22: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %b: %D = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestLessEqual.decl: %TestLessEqual.type = fn_decl @TestLessEqual [concrete = constants.%TestLessEqual] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.9dc = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.9dc = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc14_33.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc14_33.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc14_33.2: Core.Form = init_form %.loc14_33.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %D = value_param call_param0 -// CHECK:STDOUT: %D.ref.loc14_21: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %a: %D = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %D = value_param call_param1 -// CHECK:STDOUT: %D.ref.loc14_27: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %b: %D = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestGreater.decl: %TestGreater.type = fn_decl @TestGreater [concrete = constants.%TestGreater] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.9dc = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.9dc = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc22_31.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc22_31.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc22_31.2: Core.Form = init_form %.loc22_31.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %D = value_param call_param0 -// CHECK:STDOUT: %D.ref.loc22_19: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %a: %D = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %D = value_param call_param1 -// CHECK:STDOUT: %D.ref.loc22_25: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %b: %D = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: %TestGreaterEqual.decl: %TestGreaterEqual.type = fn_decl @TestGreaterEqual [concrete = constants.%TestGreaterEqual] { -// CHECK:STDOUT: %a.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%a.param_patt] -// CHECK:STDOUT: %a.patt: %pattern_type.9dc = wrapper_binding_pattern a, %a.param_patt [concrete = constants.%a.patt] -// CHECK:STDOUT: %b.param_patt: %pattern_type.9dc = value_param_pattern [concrete = constants.%b.param_patt] -// CHECK:STDOUT: %b.patt: %pattern_type.9dc = wrapper_binding_pattern b, %b.param_patt [concrete = constants.%b.patt] -// CHECK:STDOUT: %return.param_patt: %pattern_type.831 = out_param_pattern [concrete = constants.%return.param_patt] -// CHECK:STDOUT: %return.patt: %pattern_type.831 = return_slot_pattern %return.param_patt, %.loc30_36.1 [concrete = constants.%return.patt.c0c] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc30_36.1: type = type_literal bool [concrete = bool] -// CHECK:STDOUT: %.loc30_36.2: Core.Form = init_form %.loc30_36.1 [concrete = constants.%.f34] -// CHECK:STDOUT: %a.param: %D = value_param call_param0 -// CHECK:STDOUT: %D.ref.loc30_24: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %a: %D = wrapper_binding a, %a.param -// CHECK:STDOUT: %b.param: %D = value_param call_param1 -// CHECK:STDOUT: %D.ref.loc30_30: type = name_ref D, file.%D.decl [concrete = constants.%D] -// CHECK:STDOUT: %b: %D = wrapper_binding b, %b.param -// CHECK:STDOUT: %return.param: ref bool = out_param call_param2 -// CHECK:STDOUT: %return: ref bool = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: class @D { -// CHECK:STDOUT: %complete_type: = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type] -// CHECK:STDOUT: complete_type_witness = %complete_type -// CHECK:STDOUT: -// CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = constants.%D -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestLess(%a.param: %D, %b.param: %D) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %D = name_ref a, %a -// CHECK:STDOUT: %b.ref: %D = name_ref b, %b -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestLessEqual(%a.param: %D, %b.param: %D) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %D = name_ref a, %a -// CHECK:STDOUT: %b.ref: %D = name_ref b, %b -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestGreater(%a.param: %D, %b.param: %D) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %D = name_ref a, %a -// CHECK:STDOUT: %b.ref: %D = name_ref b, %b -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @TestGreaterEqual(%a.param: %D, %b.param: %D) -> out %return.param: bool { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %a.ref: %D = name_ref a, %a -// CHECK:STDOUT: %b.ref: %D = name_ref b, %b -// CHECK:STDOUT: return -// CHECK:STDOUT: } -// CHECK:STDOUT: