Support user-defined implicit conversions via ImplicitAs (#1273)

Support is added for all of the non-type expression contexts where we currently accept built-in conversions, such as reordering the fields in a struct.
This commit is contained in:
Richard Smith
2022-05-20 17:10:30 -07:00
committed by GitHub
parent e77fcded86
commit 8dd398807d
33 changed files with 999 additions and 97 deletions
+5
View File
@@ -401,6 +401,7 @@ auto Interpreter::StepLvalue() -> ErrorOr<Success> {
case ExpressionKind::ContinuationTypeLiteral:
case ExpressionKind::StringLiteral:
case ExpressionKind::StringTypeLiteral:
case ExpressionKind::ValueLiteral:
case ExpressionKind::IntrinsicExpression:
case ExpressionKind::IfExpression:
case ExpressionKind::ArrayTypeLiteral:
@@ -1042,6 +1043,10 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
CARBON_CHECK(act.pos() == 0);
return todo_.FinishAction(arena_->New<StringType>());
}
case ExpressionKind::ValueLiteral: {
CARBON_CHECK(act.pos() == 0);
return todo_.FinishAction(&cast<ValueLiteral>(exp).value());
}
case ExpressionKind::IfExpression: {
const auto& if_expr = cast<IfExpression>(exp);
if (act.pos() == 0) {