mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 19:31:08 +01:00
When performing name lookup, determine the generic instance within which the lookup result was found. (#4118)
Require types into which qualified lookup is performed to be completely defined. Eventually this will trigger substitution into the definition for generic types.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "toolchain/check/call.h"
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/generic.h"
|
||||
#include "toolchain/check/member_access.h"
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/typed_insts.h"
|
||||
@@ -37,17 +38,25 @@ static auto GetOperatorOpFunction(Context& context, Parse::AnyExprId node_id,
|
||||
return SemIR::InstId::Invalid;
|
||||
}
|
||||
|
||||
// TODO: For a parameterized interface, find the corresponding generic
|
||||
// instance.
|
||||
LookupScope scope = {.name_scope_id = interface_scope_id,
|
||||
.instance_id = SemIR::GenericInstanceId::Invalid};
|
||||
|
||||
// Lookup `Interface.Op`.
|
||||
auto op_ident_id = context.identifiers().Add(op.op_name);
|
||||
auto op_id = context.LookupQualifiedName(
|
||||
node_id, SemIR::NameId::ForIdentifier(op_ident_id), interface_scope_id,
|
||||
auto op_result = context.LookupQualifiedName(
|
||||
node_id, SemIR::NameId::ForIdentifier(op_ident_id), scope,
|
||||
/*required=*/false);
|
||||
if (!op_id.is_valid()) {
|
||||
if (!op_result.inst_id.is_valid()) {
|
||||
return SemIR::InstId::Invalid;
|
||||
}
|
||||
|
||||
// Look through import_refs and aliases.
|
||||
op_id = context.constant_values().GetConstantInstId(op_id);
|
||||
auto op_const_id =
|
||||
GetConstantInInstance(context, op_result.instance_id,
|
||||
context.constant_values().Get(op_result.inst_id));
|
||||
auto op_id = context.constant_values().GetInstId(op_const_id);
|
||||
|
||||
// We expect it to be an associated function.
|
||||
if (context.insts().Is<SemIR::AssociatedEntity>(op_id)) {
|
||||
|
||||
Reference in New Issue
Block a user