Skip to content

Commit

Permalink
Add workaround for finding 'serialize' methods in ChapelIO
Browse files Browse the repository at this point in the history
Signed-off-by: Danila Fedorin <[email protected]>
  • Loading branch information
DanilaFe committed Feb 11, 2025
1 parent 841a8d7 commit e9eb3ba
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion frontend/lib/resolution/default-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ namespace resolution {
using namespace uast;
using namespace types;

static bool isDeSerializeMethod(UniqueString name) {
return name == USTR("serialize") || name == USTR("deserialize");
}

/**
Return true if 'name' is the name of a compiler generated method.
Expand All @@ -50,7 +53,7 @@ static bool isNameOfCompilerGeneratedMethod(UniqueString name) {
return true;
}

if (name == USTR("serialize") || name == USTR("deserialize")) {
if (isDeSerializeMethod(name)) {
return true;
}

Expand Down Expand Up @@ -81,6 +84,21 @@ areOverloadsPresentInDefiningScope(Context* context,
/* receiverScopeHelper */ nullptr,
name, config);

// this ought to be solved by interfaces, but today it isn't. As a workaround
// for some standard types having their (de)serialize methods defined in
// ChapelIO, search that module too.
if (ids.numIds() == 0 && isDeSerializeMethod(name)) {
auto chapelIo =
parsing::getToplevelModule(context,
UniqueString::get(context, "ChapelIO"));
if (!chapelIo) return false;

ids = lookupNameInScope(context, scopeForModule(context, chapelIo->id()),
/* methodLookupHelper */ nullptr,
/* receiverScopeHelper */ nullptr,
name, config);
}

// nothing found
if (ids.numIds() == 0) return false;

Expand Down

0 comments on commit e9eb3ba

Please sign in to comment.