Skip to content

Commit bd2721f

Browse files
committed
generic-comment
1 parent 987d30c commit bd2721f

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

toolchain/check/handle_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ auto HandleParseNode(Context& context,
146146
// type is the interface.
147147
SemIR::TypeId self_type_id =
148148
GetInterfaceType(context, interface_id, self_specific_id);
149-
interface_info.self_param_id = GetSelfParameter(
149+
interface_info.self_param_id = GetImplicitSelfGenericParameter(
150150
context, self_type_id, interface_info.scope_id, /*is_template=*/false);
151151

152152
// Enter the interface scope.

toolchain/check/handle_named_constraint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ auto HandleParseNode(Context& context,
145145
// type is the named constraint.
146146
SemIR::TypeId self_type_id =
147147
GetNamedConstraintType(context, named_constraint_id, self_specific_id);
148-
constraint_info.self_param_id = GetSelfParameter(
148+
constraint_info.self_param_id = GetImplicitSelfGenericParameter(
149149
context, self_type_id, constraint_info.scope_id, is_template);
150150

151151
// Enter the constraint scope.

toolchain/check/interface.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ auto GetTypeForSpecificAssociatedEntity(Context& context, SemIR::LocId loc_id,
222222
CARBON_FATAL("Unexpected kind for associated constant {0}", decl);
223223
}
224224

225-
auto GetSelfParameter(Context& context, SemIR::TypeId type_id,
226-
SemIR::NameScopeId scope_id, bool is_template)
227-
-> SemIR::InstId {
225+
auto GetImplicitSelfGenericParameter(Context& context, SemIR::TypeId type_id,
226+
SemIR::NameScopeId scope_id,
227+
bool is_template) -> SemIR::InstId {
228228
auto entity_name_id = context.entity_names().AddSymbolicBindingName(
229229
SemIR::NameId::SelfType, scope_id,
230230
context.scope_stack().AddCompileTimeBinding(), is_template);
@@ -292,9 +292,11 @@ auto TryGetExistingDecl(
292292

293293
if (is_definition && existing_decl_entity->has_definition_started()) {
294294
// DiagnoseIfInvalidRedecl would diagnose an error in this case, since we'd
295-
// have two definitions. Normally we'd still use the pre-existing definition
296-
// as a forward declaration anyway, for error recovery, but we can't for
297-
// generics.
295+
// have two definitions. Given the declaration parts of the definitions
296+
// match, we would be able to use the prior declaration for error recovery,
297+
// except that having two definitions causes larger problems for generics.
298+
// All interfaces (and named constraints) are generic with an implicit Self
299+
// compile time binding.
298300
return std::nullopt;
299301
}
300302

toolchain/check/interface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ auto GetTypeForSpecificAssociatedEntity(Context& context, SemIR::LocId loc_id,
4343
-> SemIR::TypeId;
4444

4545
// Creates a symbolic binding for `Self` of type `type_id` in the scope of
46-
// `scope_id`, and add the name `Self` for the binding.
46+
// `scope_id`, and add the name `Self` for the compile time binding.
4747
//
4848
// Returns the symbolic binding instruction.
49-
auto GetSelfParameter(Context& context, SemIR::TypeId type_id,
50-
SemIR::NameScopeId scope_id, bool is_template)
51-
-> SemIR::InstId;
49+
auto GetImplicitSelfGenericParameter(Context& context, SemIR::TypeId type_id,
50+
SemIR::NameScopeId scope_id,
51+
bool is_template) -> SemIR::InstId;
5252

5353
// Given a search result `lookup_result` for `name_context`, returns the
5454
// previous valid declaration of `name_context` if there is one. Otherwise,

0 commit comments

Comments
 (0)