Skip to content

Conversation

@go-wyvern
Copy link
Member

@go-wyvern go-wyvern commented Nov 27, 2025

fix(goplus/builder#2499)

Problem Description

When handling the method overload feature, the behavior of types.Interface.Method(i) does not meet expectations.

Root Cause:

  • types.Interface uses the underlying approach to retrieve the method set when handling embeddeds
  • This approach doesn't use the types.Named type we passed through NewInterfaceType
  • The types package implementation itself is correct, but it doesn't accommodate our method overload feature requirements

Solution

Iterate through embeddeds and use types.Named to retrieve methods, ensuring proper handling of method overload scenarios.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @go-wyvern, I'm Gemini Code Assist1! 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 a crucial fix to the method lookup mechanism within the codebuild.go file. It specifically enhances the resolution process for struct types by ensuring that methods associated with embedded named types are properly identified and considered. This addresses a previously reported bug, improving the accuracy and completeness of method resolution in the system.

Highlights

  • Method Resolution Enhancement: The method lookup logic for struct types has been updated to correctly consider methods defined on embedded named types.
  • Bug Fix: This change resolves an issue where methods from embedded named types were not being properly resolved, leading to incorrect behavior in certain scenarios, specifically addressing issue #2499.
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 👍 and 👎 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.

Footnotes

  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.

@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.99%. Comparing base (dd9fe4b) to head (5682eaa).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #549      +/-   ##
==========================================
- Coverage   96.01%   95.99%   -0.02%     
==========================================
  Files          23       23              
  Lines        7358     6474     -884     
==========================================
- Hits         7065     6215     -850     
+ Misses        227      193      -34     
  Partials       66       66              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request aims to fix method lookup by considering embedded named types. The change introduces a loop to check for methods on embedded types. However, the implementation has two significant issues: it doesn't handle circular embeddings, which can lead to infinite recursion, and it fails to consider embedded pointers to named types. I've provided feedback on both points, including a critical issue regarding the potential stack overflow and a high-severity issue for the incomplete method resolution, with a code suggestion to address the latter.

@xgopilot
Copy link

xgopilot bot commented Nov 27, 2025

Code Review Summary

The fix correctly addresses method lookup for embedded named types in interfaces. The implementation is clean and follows existing patterns.

Key findings:

  • ✅ No security vulnerabilities
  • ✅ Performance impact is negligible
  • ✅ Code follows existing patterns
  • ⚠️ May need to handle non-named embedded interfaces (see inline comment)

The change is production-ready. Consider clarifying whether anonymous embedded interfaces should also be supported.

@go-wyvern go-wyvern marked this pull request as draft November 27, 2025 11:34
@go-wyvern go-wyvern marked this pull request as ready for review November 28, 2025 03:17
@xgopilot
Copy link

xgopilot bot commented Nov 28, 2025

Code Review Summary

The fix correctly addresses method resolution for embedded named interfaces. The implementation follows existing patterns and the test validates the happy path. Three noteworthy issues identified:

  1. Critical: Missing cycle detection could cause stack overflow with circular interface embeddings
  2. Important: Only Named embedded types are handled; needs documentation or extension
  3. Minor: Test coverage could include more edge cases

Overall solid fix that would benefit from defensive cycle detection before merge.

@xushiwei xushiwei merged commit 57aff40 into goplus:main Nov 28, 2025
22 of 23 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.

2 participants