mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 13:51:04 +01:00
Rename "generic instance" to "specific" throughout the toolchain. (#4165)
As discussed in toolchain meeting, we want to avoid overloading the meaning of "instance", and "specific" was the best name we found. It's a little unorthodox and inventive, but hopefully over time will become as unsurprising as the term "generic" is.
This commit is contained in:
@@ -200,18 +200,18 @@ auto DeclNameStack::LookupOrAddName(NameContext name_context,
|
||||
static auto PushNameQualifierScope(Context& context,
|
||||
SemIR::InstId scope_inst_id,
|
||||
SemIR::NameScopeId scope_id,
|
||||
SemIR::GenericInstanceId instance_id,
|
||||
SemIR::SpecificId specific_id,
|
||||
bool has_error = false) -> void {
|
||||
// If the qualifier has no parameters, we don't need to keep around a
|
||||
// parameter scope.
|
||||
context.scope_stack().PopIfEmpty();
|
||||
|
||||
// When declaring a member of a generic, resolve the self specific.
|
||||
if (instance_id.is_valid()) {
|
||||
ResolveSpecificDefinition(context, instance_id);
|
||||
if (specific_id.is_valid()) {
|
||||
ResolveSpecificDefinition(context, specific_id);
|
||||
}
|
||||
|
||||
context.scope_stack().Push(scope_inst_id, scope_id, instance_id, has_error);
|
||||
context.scope_stack().Push(scope_inst_id, scope_id, specific_id, has_error);
|
||||
|
||||
// An interface also introduces its 'Self' parameter into scope, despite it
|
||||
// not being redeclared as part of the qualifier.
|
||||
@@ -232,10 +232,10 @@ auto DeclNameStack::ApplyNameQualifier(const NameComponent& name) -> void {
|
||||
name_context.has_qualifiers = true;
|
||||
|
||||
// Resolve the qualifier as a scope and enter the new scope.
|
||||
auto [scope_id, instance_id] = ResolveAsScope(name_context, name);
|
||||
auto [scope_id, specific_id] = ResolveAsScope(name_context, name);
|
||||
if (scope_id.is_valid()) {
|
||||
PushNameQualifierScope(*context_, name_context.resolved_inst_id, scope_id,
|
||||
instance_id,
|
||||
specific_id,
|
||||
context_->name_scopes().Get(scope_id).has_error);
|
||||
name_context.parent_scope_id = scope_id;
|
||||
} else {
|
||||
@@ -366,10 +366,9 @@ static auto DiagnoseQualifiedDeclInNonScope(Context& context, SemIRLoc use_loc,
|
||||
|
||||
auto DeclNameStack::ResolveAsScope(const NameContext& name_context,
|
||||
const NameComponent& name) const
|
||||
-> std::pair<SemIR::NameScopeId, SemIR::GenericInstanceId> {
|
||||
constexpr std::pair<SemIR::NameScopeId, SemIR::GenericInstanceId>
|
||||
InvalidResult = {SemIR::NameScopeId::Invalid,
|
||||
SemIR::GenericInstanceId::Invalid};
|
||||
-> std::pair<SemIR::NameScopeId, SemIR::SpecificId> {
|
||||
constexpr std::pair<SemIR::NameScopeId, SemIR::SpecificId> InvalidResult = {
|
||||
SemIR::NameScopeId::Invalid, SemIR::SpecificId::Invalid};
|
||||
|
||||
if (!CheckQualifierIsResolved(*context_, name_context)) {
|
||||
return InvalidResult;
|
||||
@@ -396,7 +395,7 @@ auto DeclNameStack::ResolveAsScope(const NameContext& name_context,
|
||||
return InvalidResult;
|
||||
}
|
||||
return {class_info.scope_id,
|
||||
context_->generics().GetSelfInstance(class_info.generic_id)};
|
||||
context_->generics().GetSelfSpecific(class_info.generic_id)};
|
||||
}
|
||||
case CARBON_KIND(SemIR::InterfaceDecl interface_decl): {
|
||||
const auto& interface_info =
|
||||
@@ -412,7 +411,7 @@ auto DeclNameStack::ResolveAsScope(const NameContext& name_context,
|
||||
return InvalidResult;
|
||||
}
|
||||
return {interface_info.scope_id,
|
||||
context_->generics().GetSelfInstance(interface_info.generic_id)};
|
||||
context_->generics().GetSelfSpecific(interface_info.generic_id)};
|
||||
}
|
||||
case CARBON_KIND(SemIR::Namespace resolved_inst): {
|
||||
auto scope_id = resolved_inst.name_scope_id;
|
||||
@@ -432,7 +431,7 @@ auto DeclNameStack::ResolveAsScope(const NameContext& name_context,
|
||||
// be used as a name qualifier.
|
||||
scope.is_closed_import = false;
|
||||
}
|
||||
return {scope_id, SemIR::GenericInstanceId::Invalid};
|
||||
return {scope_id, SemIR::SpecificId::Invalid};
|
||||
}
|
||||
default: {
|
||||
DiagnoseQualifiedDeclInNonScope(*context_, name_context.loc_id,
|
||||
|
||||
Reference in New Issue
Block a user