Make addr me: Self* work for interface methods. (#2374)

Fixes #2223.
This commit is contained in:
Richard Smith
2022-11-07 08:11:19 -08:00
committed by GitHub
parent 9e8cacae00
commit e557d4af3b
9 changed files with 118 additions and 38 deletions
+7 -3
View File
@@ -1043,7 +1043,7 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
bool forming_member_name = isa<TypeOfMemberName>(&access.static_type());
if (act.pos() == 0) {
// First, evaluate the first operand.
if (access.is_field_addr_me_method()) {
if (access.is_addr_me_method()) {
return todo_.Spawn(std::make_unique<LValAction>(&access.object()));
} else {
return todo_.Spawn(
@@ -1119,8 +1119,12 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
bool forming_member_name = isa<TypeOfMemberName>(&access.static_type());
if (act.pos() == 0) {
// First, evaluate the first operand.
return todo_.Spawn(
std::make_unique<ExpressionAction>(&access.object()));
if (access.is_addr_me_method()) {
return todo_.Spawn(std::make_unique<LValAction>(&access.object()));
} else {
return todo_.Spawn(
std::make_unique<ExpressionAction>(&access.object()));
}
} else if (act.pos() == 1 && access.impl().has_value() &&
!forming_member_name) {
// Next, if we're accessing an interface member, evaluate the `impl`