Explorer: move subtyping logic to TypeChecker (#2484)

Addresses comments from this discussion: https://github.com/carbon-language/carbon-lang/pull/2460#discussion_r1046444433

Features:
* Move subtyping logic from Interpreter to TypeChecker, exposing subtyping as a series of access to `.base`.
    * Excludes function parameter conversion, which is still done in ::Convert due to parameters conversion being handled differently.

Changes:
* Add new `class BaseAccessExpression : public MemberAccessExpression`, allowing rewrites
* Handle `BaseAccessExpression` expression type in Interpreter
* Move subtyping logic to `TypeChecker::ImplicitlyConvert`
This commit is contained in:
Adrien Leravat
2022-12-21 19:01:02 -08:00
committed by GitHub
parent 6accdfff77
commit 026c4b9dc3
15 changed files with 226 additions and 5 deletions
+1
View File
@@ -275,6 +275,7 @@ static auto ResolveNames(Expression& expression,
break;
case ExpressionKind::ValueLiteral:
case ExpressionKind::BuiltinConvertExpression:
case ExpressionKind::BaseAccessExpression:
CARBON_FATAL() << "should not exist before type checking";
case ExpressionKind::UnimplementedExpression:
return ProgramError(expression.source_loc()) << "Unimplemented";