From 055bcab4088de2fb6ae35d66cb6666da5096162c Mon Sep 17 00:00:00 2001 From: aexzhou Date: Sun, 21 Dec 2025 21:18:35 -0800 Subject: [PATCH] Fix extending a class by a typedef (#6679) --- docs/CONTRIBUTORS | 1 + src/V3LinkDot.cpp | 17 +++++++++++++++++ test_regress/t/t_class_extends_alias.py | 8 +++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 2ca03eddd..7568093ee 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -273,6 +273,7 @@ Yutetsu TAKATSUKASA Yves Mathieu Zhanglei Wang Zhen Yan +Zhou Qinnan (Alex) Zhou Shen Zhouyi Shen Zixi Li diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index a3c62b46d..87f38cf20 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -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() diff --git a/test_regress/t/t_class_extends_alias.py b/test_regress/t/t_class_extends_alias.py index 31228c9a7..82232aeae 100755 --- a/test_regress/t/t_class_extends_alias.py +++ b/test_regress/t/t_class_extends_alias.py @@ -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() \ No newline at end of file