x/tools/refactor/satisfy: LHS reports a named Type, not an interface #66037
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Go version
go version go1.22.0 darwin/amd64
Output of
go env
in your module/workspace:What did you do?
go.mod
example2/main.go
I ran the
refactor/satisfy
tool against thisexample2
package in thescratchpad
module. The code looks roughly as below:What did you see happen?
From the refactor/satisfy docs:
However, one of the constraints returned is actually the opposite (LHS = *types.Named, RHS = *types.Interface) as compared to the expected (LHS = *types.Interface, RHS = *types.Named).
Printing this returns:
The LHS is:
*types.Named
The RHS is:
*types.Interface
What did you expect to see?
Honestly, I'm not sure.
mock.TestingT
is actually an interface (and you can see this via a call toUnderlying()
on the named type).I see two options:
*types.Interface
was correct, and the code forrefactor/satisfy
should be updated to ensure that this holds.*types.Interface
was unfounded, and I should update my code to account for potentially receiving atypes.Named
for LHS and then accessing the underlying interface.The text was updated successfully, but these errors were encountered: