mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
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:
@@ -18,6 +18,11 @@ auto GetCalleeFunction(const File& sem_ir, InstId callee_id,
|
||||
.self_type_id = InstId::None,
|
||||
.self_id = InstId::None,
|
||||
.is_error = false};
|
||||
if (auto bound_method = sem_ir.insts().TryGetAs<BoundMethod>(callee_id)) {
|
||||
result.self_id = bound_method->object_id;
|
||||
callee_id = bound_method->function_decl_id;
|
||||
}
|
||||
|
||||
if (specific_id.has_value()) {
|
||||
callee_id = sem_ir.constant_values().GetInstIdIfValid(
|
||||
GetConstantValueInSpecific(sem_ir, specific_id, callee_id));
|
||||
@@ -31,11 +36,6 @@ auto GetCalleeFunction(const File& sem_ir, InstId callee_id,
|
||||
callee_id = specific_function->callee_id;
|
||||
}
|
||||
|
||||
if (auto bound_method = sem_ir.insts().TryGetAs<BoundMethod>(callee_id)) {
|
||||
result.self_id = bound_method->object_id;
|
||||
callee_id = bound_method->function_decl_id;
|
||||
}
|
||||
|
||||
// Identify the function we're calling by its type.
|
||||
auto val_id = sem_ir.constant_values().GetConstantInstId(callee_id);
|
||||
if (!val_id.has_value()) {
|
||||
|
||||
Reference in New Issue
Block a user