gop icon indicating copy to clipboard operation
gop copied to clipboard

[WIP] cl: ast.OverloadFuncDecl preload overload func

Open visualfc opened this issue 2 months ago • 2 comments

deps by https://github.com/goplus/gogen/pull/541

  • ast.OverloadFuncDecl preload overload func
  • remove pkgCtx.overpos

visualfc avatar Oct 11 '25 11:10 visualfc

Summary of Changes

Hello @visualfc, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces fundamental changes to the compiler's preloading mechanism to properly support ast.OverloadFuncDecl. It modifies how functions and methods are registered and represented internally, enabling the compiler to recognize and manage overloaded entities. By creating specialized internal objects and a synthetic dispatcher for overloads, this change lays the groundwork for robust overload resolution within the compilation process.

Highlights

  • Enhanced Function Preloading: The preloadFuncDecl internal function now accepts an overload boolean parameter, allowing the compiler to differentiate between standard and overloaded function declarations during the initial preloading phase.
  • Specialized Overload Handling: New conditional logic has been introduced to create distinct internal representations for overloaded functions and methods. Instead of directly calling loadFunc, overloaded entities now trigger the creation of gogen.NewOverloadFunc or gogen.NewOverloadMethod objects.
  • Synthetic Overload Dispatcher: When an ast.OverloadFuncDecl is encountered, the system now generates a synthetic ast.FuncDecl that acts as an overload dispatcher. This dispatcher function is marked as overloaded and accepts a single any type parameter, facilitating runtime overload resolution.
  • New Constant for Overload Arguments: A new constant, __xgo_overload_args__, has been added to serve as the parameter name for the synthetic overload dispatcher function, ensuring consistent naming.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Oct 11 '25 11:10 gemini-code-assist[bot]

Code Review Summary

Clean implementation of overload function preloading. Three areas need attention:

Critical:

  • Line 1071: Unsafe type lookup/assertion - add nil checks to prevent panic

Documentation:

  • Line 1361: Add doc comment for overloadArgs constant
  • Line 1312-1319: Explain placeholder signature purpose

Style:

  • Line 1312-1319: Remove unnecessary & in Field literal

No performance or security vulnerabilities found beyond the nil check issue.

niupilot[bot] avatar Oct 11 '25 11:10 niupilot[bot]