When converting an expression to type type, retain the resulting instruction as well as the TypeId. (#4355)

The `TypeId` is lossy, as it represents only the canonical type, and not
the specific computation that produced it.
This commit is contained in:
Richard Smith
2024-10-01 01:49:39 +00:00
committed by GitHub
parent 9d5ec52232
commit 4ca711c175
15 changed files with 48 additions and 33 deletions
+3 -2
View File
@@ -391,7 +391,8 @@ auto HandleParseNode(Context& context, Parse::AdaptDeclId node_id) -> bool {
return true;
}
auto adapted_type_id = ExprAsType(context, node_id, adapted_type_expr_id);
auto adapted_type_id =
ExprAsType(context, node_id, adapted_type_expr_id).type_id;
adapted_type_id = context.AsCompleteType(adapted_type_id, [&] {
CARBON_DIAGNOSTIC(IncompleteTypeInAdaptDecl, Error,
"adapted type `{0}` is an incomplete type",
@@ -467,7 +468,7 @@ static auto DiagnoseBaseIsFinal(Context& context, Parse::NodeId node_id,
// Checks that the specified base type is valid.
static auto CheckBaseType(Context& context, Parse::NodeId node_id,
SemIR::InstId base_expr_id) -> BaseInfo {
auto base_type_id = ExprAsType(context, node_id, base_expr_id);
auto base_type_id = ExprAsType(context, node_id, base_expr_id).type_id;
base_type_id = context.AsCompleteType(base_type_id, [&] {
CARBON_DIAGNOSTIC(IncompleteTypeInBaseDecl, Error,
"base `{0}` is an incomplete type", SemIR::TypeId);