all: simplify and clarify some expressions (google/go-cloud#260)

This commit is contained in:
Oleg Kovalov
2018-08-06 23:49:11 +02:00
committed by Ross Light
parent 105b7fde1c
commit 0559d22dfe
3 changed files with 10 additions and 11 deletions

View File

@@ -716,19 +716,17 @@ func processValue(fset *token.FileSet, info *types.Info, call *ast.CallExpr) (*V
}
ok := true
ast.Inspect(call.Args[0], func(node ast.Node) bool {
switch node.(type) {
switch expr := node.(type) {
case nil, *ast.ArrayType, *ast.BasicLit, *ast.BinaryExpr, *ast.ChanType, *ast.CompositeLit, *ast.FuncType, *ast.Ident, *ast.IndexExpr, *ast.InterfaceType, *ast.KeyValueExpr, *ast.MapType, *ast.ParenExpr, *ast.SelectorExpr, *ast.SliceExpr, *ast.StarExpr, *ast.StructType, *ast.TypeAssertExpr:
// Good!
case *ast.UnaryExpr:
expr := node.(*ast.UnaryExpr)
if expr.Op == token.ARROW {
ok = false
return false
}
case *ast.CallExpr:
// Only acceptable if it's a type conversion.
call := node.(*ast.CallExpr)
if _, isFunc := info.TypeOf(call.Fun).(*types.Signature); isFunc {
if _, isFunc := info.TypeOf(expr.Fun).(*types.Signature); isFunc {
ok = false
return false
}