Skip to content

cl: template class with virtual methods - #872

Merged
xushiwei merged 2 commits into
goplus:mainfrom
xushiwei:q
Sep 29, 2026
Merged

xushiwei merged 2 commits into
goplus:mainfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

No description provided.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.33%. Comparing base (48caf47) to head (bf357bc).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #872      +/-   ##
==========================================
+ Coverage   85.12%   85.33%   +0.21%     
==========================================
  Files          22       22              
  Lines        1802     1821      +19     
==========================================
+ Hits         1534     1554      +20     
+ Misses        268      267       -1     
Flag Coverage Δ
llgo-tests 85.33% <100.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: template type-parameter support in vtable generation

Solid, well-scoped change. genVtable now threads the *classCtx through so a template class's type parameters flow into both the generated _xgo_vtable_X[...] struct and the XGo_vptr() receiver, and the out.go fixture confirms the intended output. Build passes.

One latent correctness issue is flagged inline. The remaining notes below are minor (naming/docs) and non-blocking.

Minor — naming & docs (cl/vtable.go)

  • cloneTypes (L148) doesn't clone — it repacks []*types.TypeParam into []types.Type for types.Instantiate. A name like typeParamsAsArgs / toTypeArgs would read truer. Same "clone" framing applies to the block generally.
  • cloneTypeName (L165) reuses obj.Type() for the new TypeName's type, whereas newTemplateParams in class.go (L90) passes nil when building the same shape. Worth aligning the two so the vtable's type params are guaranteed identical to the class's; if the obj.Type() binding is intentional, a one-line comment would help.
  • The three new helpers (cloneTypes, cloneTypeParams, cloneTypeName, L148–167) lack doc comments in an otherwise thoroughly-documented file. The doc comments on genVtable (L88) and genVptrAccessor (L169) also still describe only the non-generic *_xgo_vtable_X form; a brief note about the template ([T...]) path would keep them accurate.

No security or performance concerns: the unsafe.Pointer cast in classCtx.scope() and the deliberate panic invariants are pre-existing and untouched; new work scales with the small type-parameter count at codegen time.

Comment thread cl/vtable.go Outdated
@xushiwei
xushiwei merged commit 5fdc78f into goplus:main Sep 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant