Unify initialization and conversion logic (#3255)

Combine the initialization, implicit conversion, and value category
conversion functions into a single function.

This substantially reduces the duplication between these steps, and
ensures that we support the same set of conversions in all these
contexts. This also fixes some issues where we would not use the proper
value representation for tuples and structs after performing implicit
conversions.
This commit is contained in:
Richard Smith
2023-10-02 21:53:52 +00:00
committed by GitHub
parent 7899154a21
commit fea6cf88fc
74 changed files with 1646 additions and 1074 deletions
+2 -1
View File
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/check/context.h"
#include "toolchain/check/convert.h"
namespace Carbon::Check {
@@ -133,7 +134,7 @@ auto HandleReturnType(Context& context, Parse::Node parse_node) -> bool {
// Propagate the type expression.
auto [type_parse_node, type_node_id] =
context.node_stack().PopExpressionWithParseNode();
auto type_id = context.ExpressionAsType(type_parse_node, type_node_id);
auto type_id = ExpressionAsType(context, type_parse_node, type_node_id);
// TODO: Use a dedicated node rather than VarStorage here.
context.AddNodeAndPush(
parse_node,