all: simplify and clarify some expressions (google/go-cloud#260)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ func (g *gen) rewritePkgRefs(info *types.Info, node ast.Node) ast.Node {
|
||||
if len(scopeStack) > 0 {
|
||||
// Avoid picking a name that conflicts with other names in the
|
||||
// current scope.
|
||||
_, obj := scopeStack[len(scopeStack)-1].LookupParent(n, 0)
|
||||
_, obj := scopeStack[len(scopeStack)-1].LookupParent(n, token.NoPos)
|
||||
if obj != nil {
|
||||
return true
|
||||
}
|
||||
@@ -436,7 +436,7 @@ func (g *gen) nameInFileScope(name string) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
_, obj := g.prog.Package(g.currPackage).Pkg.Scope().LookupParent(name, 0)
|
||||
_, obj := g.prog.Package(g.currPackage).Pkg.Scope().LookupParent(name, token.NoPos)
|
||||
return obj != nil
|
||||
}
|
||||
|
||||
@@ -481,13 +481,14 @@ func injectPass(name string, params *types.Tuple, injectSig outputSignature, cal
|
||||
ig.p("%s %s", ig.paramNames[i], types.TypeString(pi.Type(), ig.g.qualifyPkg))
|
||||
}
|
||||
outTypeString := types.TypeString(injectSig.out, ig.g.qualifyPkg)
|
||||
if injectSig.cleanup && injectSig.err {
|
||||
switch {
|
||||
case injectSig.cleanup && injectSig.err:
|
||||
ig.p(") (%s, func(), error) {\n", outTypeString)
|
||||
} else if injectSig.cleanup {
|
||||
case injectSig.cleanup:
|
||||
ig.p(") (%s, func()) {\n", outTypeString)
|
||||
} else if injectSig.err {
|
||||
case injectSig.err:
|
||||
ig.p(") (%s, error) {\n", outTypeString)
|
||||
} else {
|
||||
default:
|
||||
ig.p(") %s {\n", outTypeString)
|
||||
}
|
||||
for i := range calls {
|
||||
|
||||
@@ -513,7 +513,7 @@ type dirInfo struct {
|
||||
|
||||
func (d dirInfo) Name() string { return d.name }
|
||||
func (d dirInfo) Size() int64 { return 0 }
|
||||
func (d dirInfo) Mode() os.FileMode { return os.ModeDir | 0777 }
|
||||
func (d dirInfo) Mode() os.FileMode { return os.ModeDir | os.ModePerm }
|
||||
func (d dirInfo) ModTime() time.Time { return time.Unix(0, 0) }
|
||||
func (d dirInfo) IsDir() bool { return true }
|
||||
func (d dirInfo) Sys() interface{} { return nil }
|
||||
|
||||
Reference in New Issue
Block a user