Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dyno: Default initializers for classes that inherit #26028

Merged
merged 13 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions frontend/lib/framework/ID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@ ID ID::parentSymbolId(Context* context) const {
return ID();
}

// Otherwise, construct an ID for the parent symbol
return ID(parentSymPath, -1, 0);
if (this->isFabricatedId() &&
this->fabricatedIdKind() == FabricatedIdKind::Generated) {
return ID(parentSymPath, ID_GEN_START, 0);
} else {
// Otherwise, construct an ID for the parent symbol
return ID(parentSymPath, -1, 0);
}
}

UniqueString ID::symbolName(Context* context) const {
Expand Down
4 changes: 3 additions & 1 deletion frontend/lib/parsing/parsing-queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ parseFileContainingIdToBuilderResult(Context* context,
symbolPath = id.symbolPath();
} else {
symbolPath = ID::parentSymbolPath(context, id.symbolPath());
if (symbolPath.isEmpty()) return nullptr;

// Assumption: The generated module goes only one symbol deep.
CHPL_ASSERT(ID::innermostSymbolName(context, symbolPath).startsWith("chpl__generated"));
Expand Down Expand Up @@ -1246,7 +1247,8 @@ static const AstTag& idToTagQuery(Context* context, ID id) {

AstTag result = asttags::AST_TAG_UNKNOWN;

if (!id.isFabricatedId()) {
if (!id.isFabricatedId() ||
id.fabricatedIdKind() == ID::FabricatedIdKind::Generated) {
const AstNode* ast = astForIdQuery(context, id);
if (ast != nullptr) {
result = ast->tag();
Expand Down
15 changes: 12 additions & 3 deletions frontend/lib/resolution/InitResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ InitResolver::computeTypedSignature(const Type* newRecvType) {

formalsInstantiated.resize(ufs->numFormals());

bool needsInstantiation = false;

for (int i = 0; i < tfs->numFormals(); i++) {
if (i == 0) {
auto qt = QualifiedType(determineReceiverIntent(), newRecvType);
Expand All @@ -427,12 +429,15 @@ InitResolver::computeTypedSignature(const Type* newRecvType) {
} else {
formalTypes.push_back(tfs->formalType(i));
formalsInstantiated.setBit(i, tfs->formalIsInstantiated(i));
if (tfs->formalType(i).genericity() == Type::Genericity::GENERIC) {
needsInstantiation = true;
}
}
}

ret = TypedFnSignature::get(ctx_, ufs, formalTypes,
tfs->whereClauseResult(),
/* needsInstantiation */ false,
needsInstantiation,
tfs->instantiatedFrom(),
tfs->parentFn(),
formalsInstantiated,
Expand Down Expand Up @@ -759,8 +764,12 @@ bool InitResolver::handleAssignmentToField(const OpCall* node) {

// TODO: Anything to do if the opposite is true?
if (!isAlreadyInitialized) {
auto& reRhs = initResolver_.byPostorder.byAst(rhs);
state->qt = reRhs.type();
auto rhsType = initResolver_.byPostorder.byAst(rhs).type();

auto param = state->qt.kind() == QualifiedType::PARAM ? rhsType.param() : nullptr;
auto qt = QualifiedType(state->qt.kind(), rhsType.type(), param);
state->qt = qt;

state->initPointId = node->id();
state->isInitialized = true;

Expand Down
Loading