]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: fix for changes to go/types package
authorRob Pike <r@golang.org>
Tue, 14 May 2013 22:49:58 +0000 (15:49 -0700)
committerRob Pike <r@golang.org>
Tue, 14 May 2013 22:49:58 +0000 (15:49 -0700)
Need to use (or stub) exact.Value.

R=gri
CC=golang-dev
https://golang.org/cl/9126043

src/cmd/vet/main.go
src/cmd/vet/types.go
src/cmd/vet/typestub.go

index 2fefa0b47aec332e4d8753272994a2a5f358f3fc..b3d12d09f9a8a3e67f1c6379fea7c0b54e00a971 100644 (file)
@@ -179,7 +179,7 @@ func doPackageDir(directory string) {
 
 type Package struct {
        types  map[ast.Expr]Type
-       values map[ast.Expr]interface{}
+       values map[ast.Expr]ExactValue
        files  []*File
 }
 
index 75f195b0fb9ea1c0157a2fab584f362181f191d8..46e4d94807d13b2cc664f7679746acebe9a54cbb 100644 (file)
@@ -14,19 +14,27 @@ import (
        "go/ast"
        "go/token"
 
+       "code.google.com/p/go.exp/go/exact"
        "code.google.com/p/go.exp/go/types"
 )
 
-// Type is equivalent to go/types.Type. Repeating it here allows us to avoid
-// depending on the go/types package.
+// Type is equivalent to types.Type. Repeating it here allows us to avoid
+// having main depend on the go/types package.
 type Type interface {
        String() string
 }
 
+// ExactValue is equivalent to exact.Value. Repeating it here allows us to
+// avoid having main depend on the go/exact package.
+type ExactValue interface {
+       Kind() exact.Kind
+       String() string
+}
+
 func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) error {
        pkg.types = make(map[ast.Expr]Type)
-       pkg.values = make(map[ast.Expr]interface{})
-       exprFn := func(x ast.Expr, typ types.Type, val interface{}) {
+       pkg.values = make(map[ast.Expr]ExactValue)
+       exprFn := func(x ast.Expr, typ types.Type, val exact.Value) {
                pkg.types[x] = typ
                if val != nil {
                        pkg.values[x] = val
@@ -93,10 +101,8 @@ func (f *File) matchArgType(t printfArgType, arg ast.Expr) bool {
                return t&argFloat != 0
        case types.UntypedFloat:
                // If it's integral, we can use an int format.
-               switch f.pkg.values[arg].(type) {
-               case int, int8, int16, int32, int64:
-                       return t&(argInt|argFloat) != 0
-               case uint, uint8, uint16, uint32, uint64:
+               switch f.pkg.values[arg].Kind() {
+               case exact.Int:
                        return t&(argInt|argFloat) != 0
                }
                return t&argFloat != 0
index fabbbe19ddb9ca0434b631985631114fec70f29e..74a3b13e2608bbdb5b00846e8b1484f3198e49c0 100644 (file)
@@ -15,11 +15,16 @@ import (
 )
 
 // Type is equivalent to go/types.Type. Repeating it here allows us to avoid
-// depending on the go/types package.
+// having main depend on the go/types package.
 type Type interface {
        String() string
 }
 
+// ExactValue is a stub for exact.Value. Stubbing it here allows us to
+// avoid having main depend on the go/exact package.
+type ExactValue interface {
+}
+
 func (pkg *Package) check(fs *token.FileSet, astFiles []*ast.File) error {
        return nil
 }