Skip to content

cl: llgoSupportAliasAsRecv = true; cl compileFuncOrMethod: support method with callback - #880

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

xushiwei merged 2 commits into
goplus:mainfrom
xushiwei:q

Conversation

@xushiwei

@xushiwei xushiwei commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.04%. Comparing base (1947404) to head (37ad384).
⚠️ Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #880      +/-   ##
==========================================
- Coverage   88.36%   88.04%   -0.33%     
==========================================
  Files          22       22              
  Lines        1857     1857              
==========================================
- Hits         1641     1635       -6     
- Misses        216      222       +6     
Flag Coverage Δ
llgo-tests 88.04% <100.00%> (-0.33%) ⬇️

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: enable methods for callback funcs & alias receivers

The functional change in cl/func.go is small and coherent, and the regenerated tool/_testc/clang-c-22.1.8/* fixtures consistently reflect the new output (value receivers like VirtualFileOverlay replacing pointer-receiver impl types, with matching llgo:link directives).

What the change does

  • Drops the feats&featHasCallback == 0 guard (and its TODO) so C global functions with callback parameters can now be converted to methods.
  • Flips llgoSupportAliasAsRecv from false to true, enabling alias types as method receivers.

Verified as safe/non-issues

  • featHasCallback is still detected and used in cl/type.go and cl/typedef.go; removing its use as a gate here orphans no symbol.
  • The real safety gate — the featIgnored early-return — still runs first, so no unsupported type slips through.
  • No performance regression: feats is fully computed before the branch regardless, and the newly-taken alias branch is strictly cheaper than the old one.
  • No security/trust-boundary impact: this is a compile-time generator over developer-supplied headers; type identity and linkname targets are unchanged.

Main finding — see the inline comment: flipping llgoSupportAliasAsRecv to a const true leaves the else branch in tryToMethod (lines ~228-242) statically unreachable dead code. That dead branch is also the only in-code writer of ctx.typeAbbr (lines 238-239), so the previous auto-registration of alias-type abbreviations no longer happens at runtime (ctx.typeAbbr is still read at cl/ctx.go:337 and populated from config at cl/compile.go:217). Please confirm dropping that auto-population is intentional.

Comment thread cl/func.go
@xushiwei
xushiwei merged commit 22b5633 into goplus:main Sep 30, 2026
3 of 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