gogen v1.22.0: revert overload-conflict#2699
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2699 +/- ##
=======================================
Coverage 94.12% 94.12%
=======================================
Files 32 32
Lines 10053 10054 +1
=======================================
+ Hits 9462 9463 +1
Misses 421 421
Partials 170 170 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request updates the github.com/goplus/gogen dependency to version 1.22.0 and removes several internal files related to overload conflicts. In cl/compile.go, the code was refactored to use a temporary variable for receiver types; however, feedback suggests reverting this change to simplify the logic and avoid unnecessary variable declarations.
| var recvType = d.Recv.List[0].Type | ||
| recv, ok = recvType.(*ast.Ident) | ||
| if !ok { | ||
| ctx.handleErrorf(d.Recv.List[0].Type.Pos(), d.Recv.List[0].Type.End(), "invalid recv type %v", ctx.LoadExpr(d.Recv.List[0].Type)) | ||
| ctx.handleErrorf(recvType.Pos(), recvType.End(), "invalid recv type %v", ctx.LoadExpr(recvType)) | ||
| break | ||
| } | ||
| ctx.lbinames = append(ctx.lbinames, recv) |
There was a problem hiding this comment.
The variable recvType is introduced to improve readability, but the subsequent logic for recv and ok can be simplified by directly using the type assertion on d.Recv.List[0].Type to reduce unnecessary variable declarations.
| var recvType = d.Recv.List[0].Type | |
| recv, ok = recvType.(*ast.Ident) | |
| if !ok { | |
| ctx.handleErrorf(d.Recv.List[0].Type.Pos(), d.Recv.List[0].Type.End(), "invalid recv type %v", ctx.LoadExpr(d.Recv.List[0].Type)) | |
| ctx.handleErrorf(recvType.Pos(), recvType.End(), "invalid recv type %v", ctx.LoadExpr(recvType)) | |
| break | |
| } | |
| ctx.lbinames = append(ctx.lbinames, recv) | |
| recv, ok = d.Recv.List[0].Type.(*ast.Ident) | |
| if !ok { | |
| ctx.handleErrorf(d.Recv.List[0].Type.Pos(), d.Recv.List[0].Type.End(), "invalid recv type %v", ctx.LoadExpr(d.Recv.List[0].Type)) | |
| break | |
| } | |
| ctx.lbinames = append(ctx.lbinames, recv) |
| if d.Recv != nil { | ||
| var ok bool | ||
| recv, ok = d.Recv.List[0].Type.(*ast.Ident) | ||
| var recvType = d.Recv.List[0].Type |
There was a problem hiding this comment.
Nit: idiomatic Go (and the style used elsewhere in this file, e.g. line 910) prefers := over var x = expr when no explicit type annotation is needed.
| var recvType = d.Recv.List[0].Type | |
| recvType := d.Recv.List[0].Type |
|
Clean, focused PR. The |
No description provided.