mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:10:13 +01:00
Push a scope_stack entry for match_first blocks, and handle impls being inside those scope entries. An impl should not use the `match_first` block as its "enclosing scope" for the purpose of deciding if the impl is a redecl of another impl. We should look through it to the class or namespace the impl (and match_first) are located inside. We don't yet store the relationship between the impl and its match_first block, nor then can we use it in impl lookup for prioritization.
32 lines
1017 B
C++
32 lines
1017 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/check/context.h"
|
|
#include "toolchain/check/convert.h"
|
|
#include "toolchain/check/handle.h"
|
|
|
|
namespace Carbon::Check {
|
|
|
|
auto HandleParseNode(Context& /*context*/,
|
|
Parse::MatchFirstIntroducerId /*node_id*/) -> bool {
|
|
return true;
|
|
}
|
|
|
|
auto HandleParseNode(Context& context,
|
|
Parse::MatchFirstDefinitionStartId node_id) -> bool {
|
|
auto enclosing_scope_inst_id = context.scope_stack().PeekInstId();
|
|
auto decl_id = AddInst<SemIR::MatchFirstDecl>(
|
|
context, node_id, {.enclosing_scope_inst_id = enclosing_scope_inst_id});
|
|
context.scope_stack().PushForMatchFirstBlock(decl_id);
|
|
return true;
|
|
}
|
|
|
|
auto HandleParseNode(Context& context, Parse::MatchFirstId /*node_id*/)
|
|
-> bool {
|
|
context.scope_stack().Pop();
|
|
return true;
|
|
}
|
|
|
|
} // namespace Carbon::Check
|