Reverse nesting of BoundMethod and SpecificFunction. (#5079)

During SemIR, when identifying a specific in a specific context, we'd
have to either look through a specific or through a bound method.
Canonicalize which one to look through first, by having the BoundMethod
created around a SpecificFunction instead.
This changes a lot of check tests.

TODO: As the SemIr does not currently allow removal (access to insts()
is intentionally const), the bound instruction created prior to finding
the specific is not removed from the instructions.
Options: (1) leave as is, (2) add a way to remove the previous bound,
(3) rethink how/when the BoundMethod inst is created.
This commit is contained in:
Alina Sbirlea
2025-03-08 01:34:06 +00:00
committed by GitHub
parent 820ace95e8
commit 7fd54eded0
165 changed files with 2795 additions and 1958 deletions
+6 -4
View File
@@ -34,7 +34,8 @@ fn F(b: bool, n: i32, m: i32) -> i32 {
// CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [concrete]
// CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
// CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_0.5c6, %Convert.956 [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_0.5c6, %Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete]
// CHECK:STDOUT: %array: %array_type = tuple_value (%int_0.6a9) [concrete]
// CHECK:STDOUT: }
@@ -101,9 +102,10 @@ fn F(b: bool, n: i32, m: i32) -> i32 {
// CHECK:STDOUT: %int_0.loc12_27: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
// CHECK:STDOUT: %.loc12_29.1: %tuple.type = tuple_literal (%int_0.loc12_27)
// CHECK:STDOUT: %impl.elem0: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_0.loc12_27, %impl.elem0 [concrete = constants.%Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %bound_method, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %specific_fn(%int_0.loc12_27) [concrete = constants.%int_0.6a9]
// CHECK:STDOUT: %bound_method.loc12_29.1: <bound method> = bound_method %int_0.loc12_27, %impl.elem0 [concrete = constants.%Convert.bound]
// CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc12_29.2: <bound method> = bound_method %int_0.loc12_27, %specific_fn [concrete = constants.%bound_method]
// CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc12_29.2(%int_0.loc12_27) [concrete = constants.%int_0.6a9]
// CHECK:STDOUT: %.loc12_29.2: init %i32 = converted %int_0.loc12_27, %int.convert_checked [concrete = constants.%int_0.6a9]
// CHECK:STDOUT: %int_0.loc12_29: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
// CHECK:STDOUT: %.loc12_29.3: ref %i32 = array_index %x.var, %int_0.loc12_29