Fix extending a class by a typedef (#6679)

This commit is contained in:
aexzhou 2025-12-21 21:18:35 -08:00
parent 742c0b134c
commit 055bcab408
3 changed files with 23 additions and 3 deletions

View File

@ -273,6 +273,7 @@ Yutetsu TAKATSUKASA
Yves Mathieu
Zhanglei Wang
Zhen Yan
Zhou Qinnan (Alex)
Zhou Shen
Zhouyi Shen
Zixi Li

View File

@ -5016,6 +5016,23 @@ class LinkDotResolveVisitor final : public VNVisitor {
refParamp->refDTypep(paramp);
nodep->childDTypep(refParamp);
nodep->parameterized(true);
} else if (AstTypedef* const typedefp = VN_CAST(foundp->nodep(), Typedef)) {
AstNodeDType* const unwrappedp = typedefp->subDTypep()->skipRefp(); // Unwrap typedef to get the underlying type
if (AstClassRefDType* const classRefp = VN_CAST(unwrappedp, ClassRefDType)) {
AstPin* paramsp = cpackagerefp->paramsp();
if (paramsp) {
paramsp = paramsp->cloneTree(true);
nodep->parameterized(true);
}
nodep->childDTypep(new AstClassRefDType{nodep->fileline(), classRefp->classp(), paramsp});
iterate(nodep->childDTypep());
}
else {
nodep->v3warn(E_UNSUPPORTED,
"Unsupported: " << foundp->nodep()->prettyTypeName()
<< " in 'class extends'");
return;
}
} else {
nodep->v3warn(E_UNSUPPORTED,
"Unsupported: " << foundp->nodep()->prettyTypeName()

View File

@ -9,8 +9,10 @@
import vltest_bootstrap
test.scenarios('linter')
test.scenarios('simulator')
test.lint(fails=True, expect_filename=test.golden_filename)
test.compile()
test.passes()
test.execute()
test.passes()