这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@danielgtaylor
Copy link
Owner

@danielgtaylor danielgtaylor commented Feb 9, 2024

This fixes an edge case with composition, where a single anonymous field contains a Resolve method, which would get promoted by the Go compiler and be indistinguishable from a hand-written resolver method, resulting in the method being invoked twice (once on the parent, once on the actual struct with the resolver).

Now, when a type is found that matches one of the resolver interfaces, only named fields will continue to be traversed into to find other resolvers, skipping any anonymous fields whose method has been promoted or overwritten.

Fixes #234.

@codecov
Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (42461d5) 94.39% compared to head (5aebbeb) 94.48%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
+ Coverage   94.39%   94.48%   +0.08%     
==========================================
  Files          18       18              
  Lines        2606     2609       +3     
==========================================
+ Hits         2460     2465       +5     
+ Misses        107      106       -1     
+ Partials       39       38       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danielgtaylor danielgtaylor merged commit ff83e16 into main Feb 9, 2024
@danielgtaylor danielgtaylor deleted the fix-composition-resolver-calls branch February 9, 2024 16:18
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.

Resolve() called twice

2 participants