Skip to content

Commit

Permalink
add manager record to field accessor lookup
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmad Rezaii <[email protected]>
  • Loading branch information
arezaii committed Sep 24, 2024
1 parent ef3fc7f commit ec610d3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions frontend/lib/resolution/resolution-queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit ec610d3

Please sign in to comment.