mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 10:11:06 +01:00
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:
@@ -181,6 +181,11 @@ void Expression::Print(llvm::raw_ostream& out) const {
|
||||
out << access.object() << ".(" << access.path() << ")";
|
||||
break;
|
||||
}
|
||||
case ExpressionKind::BaseAccessExpression: {
|
||||
const auto& access = cast<BaseAccessExpression>(*this);
|
||||
out << access.object() << ".base";
|
||||
break;
|
||||
}
|
||||
case ExpressionKind::TupleLiteral: {
|
||||
out << "(";
|
||||
llvm::ListSeparator sep;
|
||||
@@ -336,6 +341,7 @@ void Expression::PrintID(llvm::raw_ostream& out) const {
|
||||
case ExpressionKind::IndexExpression:
|
||||
case ExpressionKind::SimpleMemberAccessExpression:
|
||||
case ExpressionKind::CompoundMemberAccessExpression:
|
||||
case ExpressionKind::BaseAccessExpression:
|
||||
case ExpressionKind::IfExpression:
|
||||
case ExpressionKind::WhereExpression:
|
||||
case ExpressionKind::BuiltinConvertExpression:
|
||||
|
||||
Reference in New Issue
Block a user