mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 14:56:10 +01:00
disallow impl without base (#4583)
This commit is contained in:
@@ -212,6 +212,11 @@ static auto BuildFunctionDecl(Context& context,
|
||||
parent_scope_inst) {
|
||||
if (auto class_decl = parent_scope_inst->TryAs<SemIR::ClassDecl>()) {
|
||||
auto& class_info = context.classes().Get(class_decl->class_id);
|
||||
if (virtual_modifier == SemIR::Function::VirtualModifier::Impl &&
|
||||
!class_info.base_id.is_valid()) {
|
||||
CARBON_DIAGNOSTIC(ImplWithoutBase, Error, "impl without base class");
|
||||
context.emitter().Build(node_id, ImplWithoutBase).Emit();
|
||||
}
|
||||
// TODO: If this is an `impl` function, check there's a matching base
|
||||
// function that's impl or virtual.
|
||||
class_info.is_dynamic = true;
|
||||
|
||||
Reference in New Issue
Block a user