From ec610d38640cd555c6a410fd18820c8ec7dd870d Mon Sep 17 00:00:00 2001 From: Ahmad Rezaii Date: Mon, 23 Sep 2024 22:02:00 -0600 Subject: [PATCH] add manager record to field accessor lookup Signed-off-by: Ahmad Rezaii --- .../lib/resolution/resolution-queries.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/lib/resolution/resolution-queries.cpp b/frontend/lib/resolution/resolution-queries.cpp index 5b0d435f3b4..3e0374605a2 100644 --- a/frontend/lib/resolution/resolution-queries.cpp +++ b/frontend/lib/resolution/resolution-queries.cpp @@ -3043,11 +3043,23 @@ doIsCandidateApplicableInitial(Context* context, // // TODO: This doesn't have anything to do with this candidate. Shouldn't // we be handling this somewhere else? - if (auto ct = ci.actual(0).type().type()->getCompositeType()) { + auto t = ci.actual(0).type().type(); + if (auto ct = t->getCompositeType()) { if (auto containingType = isNameOfField(context, ci.name(), ct)) { auto ret = fieldAccessor(context, containingType, ci.name()); return ApplicabilityResult::success(ret); } + // help handle the case where we're calling a field accessor on a manger. + // while resolving the body of a method on owned to evaluate the applicability, + // we need to be able to resolve the field accessor on the manager. + if (auto classType = t->toClassType()) { + if (auto managerType = classType->managerRecordType(context)) { + if (auto containingType = isNameOfField(context, ci.name(), managerType)) { + auto ret = fieldAccessor(context, containingType, ci.name()); + return ApplicabilityResult::success(ret); + } + } + } } } // not a candidate @@ -3930,9 +3942,10 @@ lookupCalledExpr(Context* context, CHPL_ASSERT(ci.numActuals() >= 1); auto& qtReceiver = ci.actual(0).type(); if (auto t = qtReceiver.type()) { - if (auto compType = t->getCompositeType()) { + if (t->getCompositeType()) { + // pass the fully adorned class type and not just the basic class type receiverScopes = - Resolver::gatherReceiverAndParentScopesForType(context, compType); + Resolver::gatherReceiverAndParentScopesForType(context, t); } else if (auto cptr = t->toCPtrType()) { receiverScopes.push_back(scopeForId(context, cptr->id(context))); } else if (const ExternType* et = t->toExternType()) {