cmd/guru: implements: if selected expr is a value, use its type
...as the basis of the query, instead of reporting an error. + test Change-Id: Ie5defa98cd8dfc8e200e296c2aa02c88893cf9ac Reviewed-on: https://go-review.googlesource.com/22117 Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
9ae7e1769c
commit
0f5f9fcf9a
|
@ -88,11 +88,17 @@ func implements(q *Query) error {
|
||||||
T = recv.Type()
|
T = recv.Type()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If not a method, use the expression's type.
|
||||||
|
if T == nil {
|
||||||
|
T = qpos.info.TypeOf(path[0].(ast.Expr))
|
||||||
|
}
|
||||||
|
|
||||||
case actionType:
|
case actionType:
|
||||||
T = qpos.info.TypeOf(path[0].(ast.Expr))
|
T = qpos.info.TypeOf(path[0].(ast.Expr))
|
||||||
}
|
}
|
||||||
if T == nil {
|
if T == nil {
|
||||||
return fmt.Errorf("no type or method here")
|
return fmt.Errorf("not a type, method, or value")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find all named types, even local types (which can have
|
// Find all named types, even local types (which can have
|
||||||
|
|
|
@ -37,3 +37,8 @@ func (sorter) Swap(i, j int) {}
|
||||||
type I interface { // @implements I "I"
|
type I interface { // @implements I "I"
|
||||||
Method(*int) *int
|
Method(*int) *int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _() {
|
||||||
|
var d D
|
||||||
|
_ = d // @implements var_d "d"
|
||||||
|
}
|
||||||
|
|
|
@ -42,3 +42,9 @@ slice type sorter
|
||||||
interface type I
|
interface type I
|
||||||
is implemented by basic type lib.Type
|
is implemented by basic type lib.Type
|
||||||
|
|
||||||
|
-------- @implements var_d --------
|
||||||
|
struct type D
|
||||||
|
implements F
|
||||||
|
pointer type *D
|
||||||
|
implements FG
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue