Skip to content

Commit 39ed62d

Browse files
authored
Add facet_types() accessor to Check::Context (#4518)
Co-authored-by: Josh L <[email protected]>
1 parent e0e3055 commit 39ed62d

File tree

11 files changed

+23
-23
lines changed

11 files changed

+23
-23
lines changed

toolchain/check/context.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,8 +1186,7 @@ auto Context::TryToDefineType(SemIR::TypeId type_id,
11861186
}
11871187

11881188
if (auto facet_type = types().TryGetAs<SemIR::FacetType>(type_id)) {
1189-
const auto& facet_type_info =
1190-
sem_ir().facet_types().Get(facet_type->facet_type_id);
1189+
const auto& facet_type_info = facet_types().Get(facet_type->facet_type_id);
11911190
for (auto interface : facet_type_info.impls_constraints) {
11921191
auto interface_id = interface.interface_id;
11931192
if (!interfaces().Get(interface_id).is_defined()) {
@@ -1224,10 +1223,9 @@ auto Context::GetTypeIdForTypeConstant(SemIR::ConstantId constant_id)
12241223
auto Context::FacetTypeFromInterface(SemIR::InterfaceId interface_id,
12251224
SemIR::SpecificId specific_id)
12261225
-> SemIR::FacetType {
1227-
SemIR::FacetTypeId facet_type_id =
1228-
sem_ir().facet_types().Add(SemIR::FacetTypeInfo{
1229-
.impls_constraints = {{interface_id, specific_id}},
1230-
.requirement_block_id = SemIR::InstBlockId::Invalid});
1226+
SemIR::FacetTypeId facet_type_id = facet_types().Add(SemIR::FacetTypeInfo{
1227+
.impls_constraints = {{interface_id, specific_id}},
1228+
.requirement_block_id = SemIR::InstBlockId::Invalid});
12311229
return {.type_id = SemIR::TypeId::TypeType, .facet_type_id = facet_type_id};
12321230
}
12331231

toolchain/check/context.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ class Context {
527527
auto interfaces() -> ValueStore<SemIR::InterfaceId>& {
528528
return sem_ir().interfaces();
529529
}
530+
auto facet_types() -> CanonicalValueStore<SemIR::FacetTypeId>& {
531+
return sem_ir().facet_types();
532+
}
530533
auto impls() -> SemIR::ImplStore& { return sem_ir().impls(); }
531534
auto generics() -> SemIR::GenericStore& { return sem_ir().generics(); }
532535
auto specifics() -> SemIR::SpecificStore& { return sem_ir().specifics(); }

toolchain/check/deduce.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ class DeductionWorklist {
117117
auto AddAll(SemIR::FacetTypeId params, SemIR::FacetTypeId args,
118118
bool needs_substitution) -> void {
119119
const auto& param_impls =
120-
context_.sem_ir().facet_types().Get(params).impls_constraints;
121-
const auto& arg_impls =
122-
context_.sem_ir().facet_types().Get(args).impls_constraints;
120+
context_.facet_types().Get(params).impls_constraints;
121+
const auto& arg_impls = context_.facet_types().Get(args).impls_constraints;
123122
if (param_impls.size() != arg_impls.size()) {
124123
// TODO: Decide whether to error on this or just treat the parameter list
125124
// as non-deduced. For now we treat it as non-deduced.

toolchain/check/eval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ static auto MakeConstantForCall(EvalContext& eval_context, SemIRLoc loc,
11581158
static auto MakeFacetTypeResult(Context& context,
11591159
const SemIR::FacetTypeInfo& info, Phase phase)
11601160
-> SemIR::ConstantId {
1161-
SemIR::FacetTypeId facet_type_id = context.sem_ir().facet_types().Add(info);
1161+
SemIR::FacetTypeId facet_type_id = context.facet_types().Add(info);
11621162
return MakeConstantResult(context,
11631163
SemIR::FacetType{.type_id = SemIR::TypeId::TypeType,
11641164
.facet_type_id = facet_type_id},

toolchain/check/handle_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static auto ExtendImpl(Context& context, Parse::NodeId extend_node,
180180
return;
181181
}
182182
const SemIR::FacetTypeInfo& info =
183-
context.sem_ir().facet_types().Get(facet_type->facet_type_id);
183+
context.facet_types().Get(facet_type->facet_type_id);
184184
for (auto interface_type : info.impls_constraints) {
185185
auto& interface = context.interfaces().Get(interface_type.interface_id);
186186
if (!interface.is_defined()) {

toolchain/check/handle_index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static auto GetIndexWithArgs(Context& context, Parse::NodeId node_id,
6565
continue;
6666
}
6767
const auto& facet_type_info =
68-
context.sem_ir().facet_types().Get(facet_type->facet_type_id);
68+
context.facet_types().Get(facet_type->facet_type_id);
6969
auto interface_type = facet_type_info.TryAsSingleInterface();
7070
if (!interface_type) {
7171
continue;

toolchain/check/impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ auto BuildImplWitness(Context& context, SemIR::ImplId impl_id)
224224
return SemIR::InstId::BuiltinError;
225225
}
226226
const SemIR::FacetTypeInfo& facet_type_info =
227-
context.sem_ir().facet_types().Get(facet_type->facet_type_id);
227+
context.facet_types().Get(facet_type->facet_type_id);
228228

229229
auto interface = facet_type_info.TryAsSingleInterface();
230230
if (!interface) {

toolchain/check/impl_lookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static auto FindAssociatedImportIRs(Context& context,
6868
}
6969
case SemIR::IdKind::For<SemIR::FacetTypeId>: {
7070
const auto& facet_type_info =
71-
context.sem_ir().facet_types().Get(SemIR::FacetTypeId(arg));
71+
context.facet_types().Get(SemIR::FacetTypeId(arg));
7272
for (const auto& impl : facet_type_info.impls_constraints) {
7373
add_entity(context.interfaces().Get(impl.interface_id));
7474
}

toolchain/check/import_ref.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ class ImportRefResolver {
965965
}
966966
case CARBON_KIND(SemIR::FacetType inst): {
967967
const SemIR::FacetTypeInfo& facet_type_info =
968-
context_.sem_ir().facet_types().Get(inst.facet_type_id);
968+
context_.facet_types().Get(inst.facet_type_id);
969969
// This is specifically the facet type produced by an interface
970970
// declaration, and so should consist of a single interface.
971971
// TODO: Will also have to handle named constraints here, once those are
@@ -2015,7 +2015,7 @@ class ImportRefResolver {
20152015
context_.constant_values().GetInstId(interface_const_id));
20162016
if (auto facet_type = interface_const_inst.TryAs<SemIR::FacetType>()) {
20172017
const SemIR::FacetTypeInfo& facet_type_info =
2018-
context_.sem_ir().facet_types().Get(facet_type->facet_type_id);
2018+
context_.facet_types().Get(facet_type->facet_type_id);
20192019
auto interface_type = facet_type_info.TryAsSingleInterface();
20202020
CARBON_CHECK(interface_type);
20212021
interface_id = interface_type->interface_id;
@@ -2095,7 +2095,7 @@ class ImportRefResolver {
20952095
context_.constant_values().GetInstId(interface_const_id));
20962096
if (auto facet_type = interface_const_inst.TryAs<SemIR::FacetType>()) {
20972097
const SemIR::FacetTypeInfo& new_facet_type_info =
2098-
context_.sem_ir().facet_types().Get(facet_type->facet_type_id);
2098+
context_.facet_types().Get(facet_type->facet_type_id);
20992099
impls_constraints.append(new_facet_type_info.impls_constraints);
21002100
} else {
21012101
auto generic_interface_type =
@@ -2109,7 +2109,7 @@ class ImportRefResolver {
21092109
}
21102110
// TODO: Also process the other requirements.
21112111
SemIR::FacetTypeId facet_type_id =
2112-
context_.sem_ir().facet_types().Add(SemIR::FacetTypeInfo{
2112+
context_.facet_types().Add(SemIR::FacetTypeInfo{
21132113
.impls_constraints = impls_constraints,
21142114
.requirement_block_id = SemIR::InstBlockId::Invalid});
21152115
return ResolveAs<SemIR::FacetType>(

toolchain/check/member_access.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static auto GetAsLookupScope(Context& context, SemIR::LocId loc_id,
5656
loc_id, QualifiedExprInUndefinedInterfaceScope, base_id);
5757
});
5858
const auto& facet_type_info =
59-
context.sem_ir().facet_types().Get(base_as_facet_type->facet_type_id);
59+
context.facet_types().Get(base_as_facet_type->facet_type_id);
6060
auto base_as_interface = facet_type_info.TryAsSingleInterface();
6161
if (base_as_interface) {
6262
auto& interface_info =
@@ -184,7 +184,7 @@ static auto PerformImplLookup(
184184
auto facet_type =
185185
context.types().GetAs<SemIR::FacetType>(assoc_type.interface_type_id);
186186
const auto& facet_type_info =
187-
context.sem_ir().facet_types().Get(facet_type.facet_type_id);
187+
context.facet_types().Get(facet_type.facet_type_id);
188188
auto interface_type = facet_type_info.TryAsSingleInterface();
189189
if (!interface_type) {
190190
context.TODO(loc_id,

0 commit comments

Comments
 (0)