Repository navigation
cl compileFuncOrMethod: remove clsName; ctx.genAsMethod: self as recv - #950
Conversation
There was a problem hiding this comment.
Review summary
Clean refactor of the C-to-method logical-class handling plus a test-fixture addition. The changes are small and well-scoped:
cl/func.go— removes theclsNamelocal and passestypNamedirectly tofuncName(). Verified behavior-preserving: when a function resolves to a logical class distinct from its receiver (cls != "" && cls != typName),typNameis already reassigned toclsat line 154 beforefnNameis computed at line 165, so the value handed tofuncNameis identical across every path.cl/logical.go— renames the generatedAs<Class>receiver fromoto the sharedc2goMethodRecvName("self") and references the resolved param via.Val(recv)instead of the string-keyed.VarVal("o"). More robust (no name-drift risk) and consistent with the generated output.- test fixtures —
PyList_SetItem(void, 3 params) correctly maps tofunc (self *List) SetItem(index, value *Object)with the matching//llgo:linkdirective, mirroring the existingPyList_GetItem->Itempattern.
Security (unsafe.Pointer reinterpret in AsList) is layout-safe via first-field struct embedding, nil-safe, and operates only on opaque FFI handles. No performance concerns.
One stale doc comment flagged inline.
Minor (optional)
The synthesized As<Class> receiver in genAsMethod is unconditionally named self, while tryToMethod (cl/func.go:255,271) only applies c2goMethodRecvName when ctx.stdRecvName is true. This asymmetry is pre-existing (the old code hardcoded o the same way) and not introduced by this PR — noting only in case uniform receiver naming under stdRecvName=false is desired.
Findings without inline locations
cl/logical.go:43: Stale receiver name here. This PR renamed the generatedAs<Class>receiver fromotoself(updating thegenAsMethoddoc at line 108 and the inline comment at line 133), but this package-level example still showso:
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #950 +/- ##
==========================================
+ Coverage 87.95% 87.97% +0.01%
==========================================
Files 23 23
Lines 2665 2661 -4
==========================================
- Hits 2344 2341 -3
+ Misses 321 320 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
MethodCheck— Logical-Type Method Detection in llcppg #945