Unreviewed changes
3 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: refactor/satisfy/find.go
Insertions: 4, Deletions: 5.
@@ -395,11 +395,10 @@
f.expr(e.X)
case *ast.SelectorExpr:
- if _, ok := f.info.Selections[e]; ok {
- if tv, ok := f.info.Types[e.X]; ok && tv.IsType() {
- // If e.X is a type (e.g., e is interface{ m() }.m), don't visit it.
- } else {
- f.expr(e.X) // selection
+ if seln, ok := f.info.Selections[e]; ok {
+ // If e.X is a type (e.g., e is interface{ m() }.m), don't visit it.
+ if seln.Kind() != types.MethodExpr {
+ f.expr(e.X)
}
} else {
return f.info.Uses[e.Sel].Type() // qualified identifier
```
Change information
Commit message:
refactor/satisfy: fix panic on interface literals
The inspection of the AST in Find() results in a panic
when you have a method expression of an anonymous
interface, because it does not expect an
interface type literal to appear as an expression.
However, this is valid Go code:
// panics on interface{ m() } after visiting e.X in the SelectorExpr e
var _ = interface{ m() }.m
During the AST traversal, if we encounter a SelectorExpr e
where e.X is a type (like interface{Baz()}), we don't need
to visit e.X.
This also fixes a panic in the printf analyzer,
which uses Find to get interface/implementation relations.
Fixes golang/go#77625
Change-Id: I431b70e2c7e3cc9b2db655e99fdb25c223a1a082
Files:
- M refactor/satisfy/find.go
- M refactor/satisfy/find_test.go
Change size: S
Delta: 2 files changed, 8 insertions(+), 2 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Alan Donovan, +2 by Mark Freeman
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI